【问题标题】:Gnuplot animation, how to print text from data file to graphGnuplot动画,如何将文本从数据文件打印到图形
【发布时间】:2021-11-24 18:12:39
【问题描述】:

我想绘制第 1 列和第 2 列,并从数据文件中打印第 3 列,但是我找不到如何从数据文件中直接读取到 x 或数组 x(n),基本上操作是这样的:

do for[j=0:n:1]{
    unset label
    x = #row j, column 3 of 'file-name.dat'
    set label x at 2000, 4000 ...
    plot 'file-name.dat' u 1:2 ....
}

【问题讨论】:

  • 请明确您想要在情节中出现的确切内容。 gnuplot 完全能够通过with labels 绘图样式直接从数据文件中绘制文本。

标签: file animation printing gnuplot


【解决方案1】:

你的问题不是很清楚。请始终提供示例数据。您的数据看起来如何以及您想要绘制的究竟是什么?您要绘制完整的第 1 列和第 2 列还是仅绘制行 j?检查以下示例并检查help everyhelp labels

代码:

### plotting labels for animation
reset session

set term gif animate delay 50
set output "SO70101046.gif"

$Data <<EOD
0   0   Time0
1   1   Time1
2   2   Time2
3   3   Time3
4   4   Time4
5   5   Time5
EOD

stats $Data nooutput   # get the number of rows
N = STATS_records

set xrange[-1:6]
set yrange[-1:6]

do for [j=0:N-1] {
    plot $Data u 1:2 every ::j::j w lp pt 7 title "Data", \
         ''    u (0):(5):3 every ::j::j w labels notitle
}
set output
### end of code

结果:

【讨论】:

  • 谢谢!!!!我将数据文件中的第 3 列从浮点数更改为字符串,您的解决方案有效。
  • @akvadiv 很高兴听到。在 StackOverflow 上:Upvote=answer 很有帮助,Accept=answer 解决了问题。
猜你喜欢
  • 2020-05-13
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-08-07
  • 2018-08-13
  • 2012-08-19
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多