linux - 通过对列进行分组,使用 gnuplot 绘制多个图

标签 linux plot gnuplot octave

我有一个数据文件,其模式为“对象参数输出1输出2……输出k”。例如。

A 0.1 0.2 0.43 0.81 0.60
0.2 0.1 0.42 0.83 0.62
0.3 0.5 0.48 0.84 0.65
B 0.1 0.1 0.42 0.83 0.62
B 0.2 0.1 0.82 0.93 0.61
B 0.3 0.5 0.48 0.34 0.15
...

我想创建多个图,每个图对应一个对象,x 轴是参数,系列是输出。目前,我编写了一个 python 脚本,它将每个对象的行转储到不同的文件中,然后调用 gnuplot.有没有更优雅的方式来绘制它?

最佳答案

您正在寻找这个:

plot 'data.txt' using (strcol(1) eq "A" ? $2 : 1/0):4 with line

其结果是: enter image description here

如果您想为每个对象创建绘图,请使用:

do for [object in "A B"] {
  reset
  set title sprintf("Object %s",object)
  plot 'data.txt' using (strcol(1) eq object ? $2 : 1/0):4 notitle with line
  pause -1
}

只需按 Enter 即可查看下一个绘图。 当然,您也可以将这些图导出到文件中。

关于linux - 通过对列进行分组,使用 gnuplot 绘制多个图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19043535/

相关文章:

Linux:.sh 脚本中的程序没有输出

linux - ubuntu 备份管理器权限被拒绝

linux - 仅使用新文件推送到远程时出现 Git 权限错误

linux - 在 shell 脚本中发送包含多个文件的邮件

python - 如何在不添加 "ticks"的情况下从下到上移动标签

python - savefig 循环将以前的图添加到图中

python - 色阶 - 接近但不够接近

gnuplot:注释行后的换行符

gnuplot - 在 gnuplot 中旋转和证明抽动

gnuplot - 如何从 CLI 调用 gnuplot 并将输出图形保存到图像文件?