Gnuplot group by days

本秂侑毒 提交于 2021-02-08 07:23:01

问题


Is it possible to plot one bar per each day, where day value consists of sum of all values in the given day? And if yes, is it possible to divide each "sum" bar into its sum components?

Let the data be

2017-09-25 13:56:51 10
2017-09-25 13:56:53 20
2017-09-25 19:20:53 30
2017-09-26 11:56:53 40
2017-09-26 13:17:02 20
2017-09-27 12:56:53 10
2017-09-28 09:56:54 30
2017-09-28 23:56:54 50

And the desired output

80                                           B
70                                           B
60       C           B                       B
50       C           B                       B
40       C           A                       B
30       B           A                       A
20       B           A                       A
10       A           A           A           A
 0   2017-09-25  2017-09-26  2017-09-27  2017-09-28

The colors do not have to be same across all columns, it is just for separating the sum components.

So far I have managed to plot just the bars, each per record:

set title "Durations sum per day"
unset multiplot
set xdata time
set style data boxes
set timefmt "%Y-%m-%d %H:%M:%S"
set format x "%m-%d\n%H:%M"
set xlabel "Day"
set ylabel "Duration sum"
set autoscale y
plot "my-data" using 1:3 t "duration [s]" with impulses linewidth 10

回答1:


You simply ignore the time for your plot and only use the date

plot dataf us (timecolumn(1,"%Y-%m-%d")):3 smooth freq with imp

and in the other case this should work

stats dataf us (timecolumn(1,"%Y-%m-%d"))
set style histogram columnstacked
plot for [i=STATS_min:STATS_max:60*60*24] dataf us (timecolumn(1,"%Y-%m-%d")==i?$3:NaN) w imp lw 10 title strftime("%Y-%m-%d",i)

but somehow "columnstacked" does not work with "plot for []"



来源:https://stackoverflow.com/questions/46405955/gnuplot-group-by-days

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!