Gnuplot:具有不同键的多个直方图

Gnuplot:具有不同键的多个直方图,plot,gnuplot,histogram,Plot,Gnuplot,Histogram,我想使用gnuplot在同一个图上绘制多个行堆叠直方图。示例数据文件如下所示: App1 20 30 50 App2 10 20 70 我使用的脚本是 set terminal jpeg medium set output "histo.jpeg" set boxwidth 0.75 absolute set style fill solid 1.00 border -1 set style data histogram set style histogram rowstacked set x

我想使用gnuplot在同一个图上绘制多个行堆叠直方图。示例数据文件如下所示:

App1 20 30 50
App2 10 20 70
我使用的脚本是

set terminal jpeg medium
set output "histo.jpeg"
set boxwidth 0.75 absolute
set style fill solid 1.00 border -1
set style data histogram
set style histogram rowstacked
set xtics 1000 nomirror
set ytics 100 nomirror
set mxtics 2
set mytics 2
set ytics 10
set yrange [0:120]
set ylabel "Total time"
set key below vertical

plot 'data' using 2 t "Idle", '' using 3 t "User space", '' using 4 :xtic(1) t "Kernel space"
我得到的结果是:

我希望在每个直方图下面有单独的键,因为我想显示每个元素占用的时间量,这在不同的图形中是不同的。此外,可能出现在一个直方图上的某些元素不会出现在另一个直方图上

我的意图是创建一个同时生成数据文件和gnuplot脚本的脚本来自动化这个过程

我使用jgraph实现了上述功能,但从外观上看效果很差

非常感谢


Spap

不幸的是,没有干净的方法可以做到这一点。您可以通过第一次绘制数据(在多点打印中),然后进行“空”绘制以在事后添加更多键来实现类似的效果

set boxwidth 0.75 absolute 
set style fill solid 1.00 border -1
set style data histogram
set style histogram rowstacked
set xtics 1000 nomirror
set ytics 100 nomirror
set mxtics 2
set mytics 2
set ytics 10
set yrange [0:120]
set ylabel "Total time"
set multiplot

#These might be helpful to keep all the "plots" aligned.
set lmargin at screen .2
set rmargin at screen .9
set tmargin at screen .9
set bmargin at screen .2

set key at first .5,screen .1 #could be "set key at screen 0.1,0.1"  You'll have to play around with it.

plot 'data' using 2 t "Idle", \
     '' using 3 t "User space", \
     '' using 4 :xtic(1) t "Kernel space"

unset xtics
unset xlabel
unset ytics
unset ylabel
unset title
unset border 
set xrange [GPVAL_X_MIN:GPVAL_X_MAX]

set key at first 1.5,screen .1 
plot NaN t "Idle (app2)" w boxes, \
     NaN t "User space (app2)" w boxes, \
     NaN t "Kernel space (app2)" w boxes

unset multiplot

谢谢,成功了!这正是我想要的。太糟糕了,它不是一个内置功能。@Spap--是的,gnuplot有一些我偶尔会想到的“单例”(key和palete)是我脑海中能想到的两个。