在 Gnuplot 中标记数据点很简单,在这个例子中,我使用第三列作为这个数据集 (data.txt) 的标签:
1 -22 "Event 0"
2 -139.7 "Event 3"
3 -11 "Event 7"
4 -35.2 "Event 6"
5 -139.7 "Event 2"
6 -139.7 "Event 4"
7 -84.7 "Event 1"
8 -22 "Event 9"
9 -64.9 "Event 8"
10 -38.5 "Event 5"
gnuplot> plot 'data.txt' u 1:2, "" u 1:2:3 w labels rotate offset 1
这是结果(为此我省略了抛光):
但是,我需要按累积总和绘制的数据点:
gnuplot> plot 'data.txt' u 1:2 smooth cumulative
现在,我如何在新的“坐标”上标记点?像这样的东西不起作用(我希望累积曲线的每个膝盖中的标签都向下):
gnuplot> plot 'data.txt' u 1:2 s cum, "" u 1:2:3 s cum w labels offset 1
结果应该是这样的(这里用 Gimp 手动剪切和定位):
最佳答案
您可以将累积图绘制到文件中,然后像使用常规数据文件一样使用这些修改后的数据。要访问标签,可以使用 paste 命令并使用额外的列:
set table "cumulative_labels"
plot 'data.txt' u 1:2:3 smooth cumulative w labels
set table "cumulative_data"
plot 'data.txt' u 1:2 smooth cumulative
unset table
plot 'cumulative_data' u 1:2 w l, \
"< paste cumulative_labels cumulative_data" u 4:5:3 w labels offset 1
编辑:
只使用 gnuplot 的方法来做到这一点,没有中间文件,但删除
smooth cumulative
选项:sum = 0.
plot "data.txt" u 1:2 s cum, "" u (sum = sum + $2, $1):(sum):3 w labels offset 1
关于plot - 使用 Gnuplot 标记累积图的数据点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36342490/