当谷歌搜索“水平 gnuplot 条形图”时,我能找到的第一个结果http://www.phyast.pitt.edu/~zov1/gnuplot/html/histogram.html建议旋转(!)最终的条形图,这看起来相当巴洛克. 尽管如此,我尝试了这种方法,但标签被切断了。
reset
$heights << EOD
dad 181
mom 170
son 100
daughter 60
EOD
set yrange [0:*] # start at zero, find max from the data
set boxwidth 0.5 # use a fixed width for boxes
unset key # turn off all titles
set style fill solid # solid color boxes
set colors podo
set xtic rotate by 90 scale 0
unset ytics
set y2tics rotate by 90
plot '$heights' using 0:2:($0+1):xtic(1) with boxes lc variable
有没有更好的方法?
您所指的链接来自大约。2009. gnuplot 从那时起得到发展。正如@Christoph 建议的那样,检查help boxxyerror
.
代码:
### horizontal bar graph
reset session
$Data << EOD
dad 181
mom 170
son 100
daughter 60
EOD
set yrange [0:*] # start at zero, find max from the data
set style fill solid # solid color boxes
unset key # turn off all titles
myBoxWidth = 0.8
set offsets 0,0,0.5-myBoxWidth/2.,0.5
plot $Data using 2:0:(0):2:($0-myBoxWidth/2.):($0+myBoxWidth/2.):($0+1):ytic(1) with boxxyerror lc var
### end of code
结果:
添加:
是什么
2:0:(0):2:($0-myBoxWidth/2.):($0+myBoxWidth/2.):($0+1):ytic(1)
意思?
嗯,它看起来比它更复杂。检查help boxxyerror
。从手册:
6 列:
x y xlow xhigh ylow yhigh
所以,总而言之:
0
,它是从零开始的行号,检查help pseudocolumns
,但在这里也不太相关(0)
表示固定值为零($0-myBoxWidth/2.)
, 行号减去 boxwidth 的一半($0+myBoxWidth/2.)
,行号加上框宽的一半($0+1)
连同... lc var
:颜色取决于从 1 开始的行号ytic(1)
: 第 1 列作为 ytic 标签出于某种原因(我不知道),gnuplot 似乎仍然没有方便的水平直方图绘制样式,但至少它提供了这种boxxyerror
解决方法。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句