gnuplot:未绘制超出 canvas 的标签

gnuplot: label overflowing outside canvas isn't drawn

我将标签放在直方图条的顶部(偏移 10),如下所示:

plot "hist.txt" using 1:2 with boxes ls 1, "hist.txt" using 1:(+10):(sprintf("%.1f%%",)) with labels

当柱值为 87% 时,绘制标签。

当条形值为 92% 时,未绘制标签,可能是因为剩余 space 不够。我如何告诉它无论如何都要绘制标签,我不介意它是否会溢出预期的 canvas 大小?

假设你将y轴的范围限制在0~100之间,y值92 + 10(= 102)将不会被绘制,因为它超过了yrange的最大值

如果您使用 with labels offset 0, first 10 作为绘图样式规范而不是移动标签在 using 中的位置,效果会很好。

set key noautotitle

set tmargin screen 0.85
set xrange [0:11]
set yrange [0:100]

plot "hist.txt" using 1:2 with boxes ls 1, \
     "hist.txt" using 1:2:(sprintf("%.1f%%",)) with labels offset 0,first 10

样本“hist.txt”是,

1 30
2 60
3 87
4 92
5 50
6 20
7 10
8 30
9 50
10 40