我沿 x 轴有一个非常密集的数据集,并使用 with boxes
绘制它作为直方图。我的数据表有 x 轴标签的条目。 x 标签变得过于密集。我怎么说只打印其中的 10 个。
plot 'histo.raw' using 3:xtic(2) with boxes lc rgb 'orange' title 'data'
样本数据:
130 " +0.145 -> +0.150" 0 0.00
131 " +0.150 -> +0.155" 0 0.00
132 " +0.155 -> +0.160" 0 0.00
133 " +0.160 -> +0.165" 1 0.00
134 " +0.165 -> +0.170" 2 0.00
135 " +0.170 -> +0.175" 2 0.00
136 " +0.175 -> +0.180" 4 0.00
137 " +0.180 -> +0.185" 9 0.01
138 " +0.185 -> +0.190" 31 0.03
139 " +0.190 -> +0.195" 74 0.07
140 " +0.195 -> +0.200" 114 0.11
141 " +0.200 -> +0.205" 126 0.13
142 " +0.205 -> +0.210" 114 0.11
143 " +0.210 -> +0.215" 120 0.12
144 " +0.215 -> +0.220" 181 0.18
145 " +0.220 -> +0.225" 216 0.22
146 " +0.225 -> +0.230" 367 0.37
147 " +0.230 -> +0.235" 503 0.50
148 " +0.235 -> +0.240" 648 0.65
149 " +0.240 -> +0.245" 788 0.79
150 " +0.245 -> +0.250" 960 0.96
如果我这样做,即
set xtics 0,10 in rotate by 90 offset first +0.5,0 right
plot 'histo.raw' using 3 with boxes lc rgb 'orange' title 'data'
我得到了所需的间隔标签。但是我的数据文件中的标签文本消失了,只是被行数替换了(我不想要)
感谢您的反馈意见。
最佳答案
您可以更换 using 3:xtic(2)
使用仅当行号 $0
才产生标签的表达式可以被 10 整除:
plot 'histo.raw' \
using 3:xtic((int($0) % 10)==0?stringcolumn(2):"") \
with boxes lc rgb 'orange' title 'data'
关于label - Gnuplot 使用来自数据的 xtic 但仅每 10 次绘制一次,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50340829/