plot - 使用 Gnuplot 标记累积图的数据点

标签 plot label gnuplot cumulative-sum

在 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

这是结果(为此我省略了抛光):
enter image description here

但是,我需要按累积总和绘制的数据点:
gnuplot> plot 'data.txt' u 1:2 smooth cumulative

enter image description here

现在,我如何在新的“坐标”上标记点?像这样的东西不起作用(我希望累积曲线的每个膝盖中的标签都向下):
gnuplot> plot 'data.txt' u 1:2 s cum, "" u 1:2:3 s cum w labels offset 1

enter image description here

结果应该是这样的(这里用 Gimp 手动剪切和定位):
enter image description here

最佳答案

您可以将累积图绘制到文件中,然后像使用常规数据文件一样使用这些修改后的数据。要访问标签,可以使用 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/

相关文章:

python - 使用 Matplotlib 在 Python 中绘制时间

使用显示一些标签的调色板绘制 gnuplot

r - 为绘图添加额外的图例

Gnuplot 扩展绘图以填充区域

matlab - Shading 命令在 MATLAB 和 Octave 中产生不同的结果

绘制 2d xy 图的算法

netlogo - 识别聚集 Netlogo 模型中的子组

python - 在Python中打开标签中的txt文件

r - 将希腊字符和星号 (*) 添加到轴标题

graph - 如何在 gnuplot 中绘制条形图?