我在x轴上有一个非常密集的数据集,并使用它with boxes作为直方图进行绘制。我的数据表中有x轴标签的条目。x标签变得太密集。我怎么说只打印每十分之一。
plot 'histo.raw' using 3:xtic(2) with boxes lc rgb 'orange' title 'data'
Run Code Online (Sandbox Code Playgroud)
样本数据:
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
Run Code Online (Sandbox Code Playgroud)
如果我这样做
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'
Run Code Online (Sandbox Code Playgroud)
我得到所需的间隔标签。但是我的数据文件中的标签文本不见了,而是被行数替换了(我不想要)
感谢您的反馈意见。
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'
Run Code Online (Sandbox Code Playgroud)