我正在尝试绘制具有断开的x轴的直方图。我从这个post学到了基本的解决方案。
但是,直方图的x轴基于字符串,而不是数字。它是这样的:
set terminal pdf
set output "test-bar.pdf"
set boxwidth 1.0 absolute
set style fill solid 1 border 0
set datafile separator ','
set style data histograms
set xtics nomirror rotate by -45
set ylabel 'Normalized Overhead (%)'
set grid ytics
set yrange [0:10]
plot 'test-bar.csv' using 2:xtic(1) lc rgb "#1E90FF" title ''
数据列出如下:
expand , 8.63390441828
cut , 6.84657194596
sync , 6.03615235627
fold , 4.22117995557
nl , 3.54228486647
truncate , 2.66222961714
tr , 2.38357169059
stty , 2.28166797757
users , 2.04211869831
factor , 1.81517270821
tac , 1.790947574
uniq , 1.78799489138
mv , 1.75054704603
mktemp , 1.72228202368
dircolors , 1.6974169738
现在情节就是这样:
如果我想利用broken axis
功能,请在stty
和users
之间插入损坏,我该怎么做?
我清楚了吗?感谢。
答案 0 :(得分:1)
虽然您使用数据文件中的xtic标签,但xtics放在整数x值处,从0
开始。现在,在绘制直方图时,无法直接设置任意x值。您必须使用newhistogram at ...
将直方图的第二部分进一步向右移动:
split = 8
plot 'test-bar.csv' using 2:xtic(1) every ::0::(split-1) lt 1,\
newhistogram at split+1,\
'' using 2:xtic(1) every ::split lt 1
绘制上下边框以及断轴标志,如您链接的帖子所示。可能的完整脚本可能是
set terminal pdf
set output "test-bar.pdf"
set boxwidth 0.5 absolute
set style fill solid 1 border 0
set datafile separator ','
set style data histograms
set style histogram rowstacked
set xtics nomirror rotate by -45
set ylabel 'Normalized Overhead (%)'
set grid ytics
set yrange [0:10]
unset key
set border 2+8
set linetype 1 lc rgb "#1E90FF"
split=8
dx = 0.125
dy = 0.03
do for [i=0:1] {
set arrow 1+i from graph 0,graph i to first split-dx,graph i lt -1 nohead
set arrow 3+i from first split+dx,graph i to graph 1,graph i lt -1 nohead
set arrow 5+i from first split-2*dx,graph i-dy to first split,graph i+dy lt -1 nohead
set arrow 7+i from first split,graph i-dy to split+2*dx,graph i+dy lt -1 nohead
}
plot 'test-bar.csv' using 2:xtic(1) every ::0::(split-1) lt 1,\
newhistogram at split+1,\
'' using 2:xtic(1) every ::split lt 1
或者,如果您不添加或堆叠更多列,则可以使用boxes
绘图样式,这样您就可以使用正常的数字轴。