Gnuplot的replot命令不生成图表。

huangapple go评论111阅读模式
英文:

Gnuplot replot command doesn't build a plot

问题

  1. #!/usr/bin/gnuplot -persist
  2. reset
  3. NO_ANIMATION = 1
  4. set terminal png size 1920, 1080
  5. set output 'graph1.png'
  6. set size 1, 1
  7. set key left box
  8. set title "Piecewise Linear Plot"
  9. set xlabel "Number of Elements, Count"
  10. set ylabel "Time, µs"
  11. set grid
  12. plot './preproc/average_O0_A0_S0.txt' with linespoints title 'O0 a[i]' lc "red"
  13. replot './preproc/average_O0_A1_S0.txt' with linespoints title 'O0 *(a + n)' lc "blue"
  14. replot './preproc/average_O0_A2_S0.txt' with linespoints title "O0 *p" lc "green"
  15. replot './preproc/average_O2_A0_S0.txt' with linespoints title "O2 a[i]" lc "yellow"
  16. replot './preproc/average_O2_A1_S0.txt' with linespoints title "O2 *(a + n)" lc "black"
  17. replot './preproc/average_O2_A2_S0.txt' with linespoints title "O2 *p" lc "purple"
英文:
  1. #!/usr/bin/gnuplot -persist
  2. reset
  3. NO_ANIMATION = 1
  4. set terminal png size 1920, 1080
  5. set output 'graph1.png'
  6. set size 1, 1
  7. set key left box
  8. set title "Кусочно-линейный график"
  9. set xlabel "Количество элементов, шт"
  10. set ylabel "Время, мкс"
  11. set grid
  12. plot './preproc/average_O0_A0_S0.txt' with linespoints title 'O0 a[i]' lc "red"
  13. replot './preproc/average_O0_A1_S0.txt' with linespoints title 'O0 *(a + n)' lc "blue"
  14. replot './preproc/average_O0_A2_S0.txt' with linespoints title "O0 *p" lc "green"
  15. replot './preproc/average_O2_A0_S0.txt' with linespoints title "O2 a[i]" lc "yellow"
  16. replot './preproc/average_O2_A1_S0.txt' with linespoints title "O2 *(a + n)" lc "black"
  17. replot './preproc/average_O2_A2_S0.txt' with linespoints title "O2 *p" lc "purple"

I use this Gnuplot code to build 6 plots in one png image. But the replot commands don't work. Only the first plot is built. The image is attached (press the button). All used files exist and have the same structure as the first one. Thank you.

答案1

得分: 0

一个 PNG 文件只能包含一幅图像。这是 PNG 格式的限制。另外,我认为 "replot" 命令在任何情况下都不是您想要的。请扩展您的问题,描述结果应该是什么样子的。

编辑

我需要在一个坐标系中有 6 条线,它们应该共享相同的坐标轴。

在这种情况下,您只需使用单个绘图命令,将各个组件用逗号分隔(参见 theozh 的回答)。

英文:

A png file can only contain one image. That is a limitation of the PNG format. Also - I think the "replot" command is not what you want in any case. Please expand your question to decribe what the result should look like.

edit
> I need 6 lines in one coordinate system, they should share the same axes

In that case you want only a single plot command with the individual components separated by commas (see response from theozh).

答案2

得分: 0

你从哪里得到了replot命令?

如果你需要在一个坐标系统中使用6条线,你只需要将绘图元素用,分隔,查看help plot

语法:

  1. plot {<ranges>} <plot-element> {, <plot-element>, <plot-element>}

此外,这里还有\用于继续下一行(提高可读性)。
查看PDF手册中的“Introduction”:

通过在每一行的末尾添加反斜杠(\),可以使命令跨越多行输入。反斜杠必须是每一行的最后一个字符。其效果就好像反斜杠和换行符不存在一样。

  1. plot './preproc/average_O0_A0_S0.txt' w lp title 'O0 a[i]' lc "red", \
  2. './preproc/average_O0_A1_S0.txt' w lp title 'O0 *(a + n)' lc "blue", \
  3. './preproc/average_O0_A2_S0.txt' w lp title "O0 *p" lc "green", \
  4. './preproc/average_O2_A0_S0.txt' w lp title "O2 a[i]" lc "yellow", \
  5. './preproc/average_O2_A1_S0.txt' w lp title "O2 *(a + n)" lc "black", \
  6. './preproc/average_O2_A2_S0.txt' w lp title "O2 *p" lc "purple"
英文:

From where did you get that replot command?

If you need 6 lines in one coordinate system, you simple add the plot elements separated with , check help plot:

> Syntax:
>
> plot {<ranges>} <plot-element> {, <plot-element>, <plot-element>}

And here additionally \ for continuing the line (better readability).
Check PDF manual "Introduction":

> Commands may extend over several input lines by ending each line but the last with a backslash (\). The
backslash must be the last character on each line. The effect is as if the backslash and newline were not there.

  1. plot &#39;./preproc/average_O0_A0_S0.txt&#39; w lp title &#39;O0 a[i]&#39; lc &quot;red&quot;, \
  2. &#39;./preproc/average_O0_A1_S0.txt&#39; w lp title &#39;O0 *(a + n)&#39; lc &quot;blue&quot;, \
  3. &#39;./preproc/average_O0_A2_S0.txt&#39; w lp title &quot;O0 *p&quot; lc &quot;green&quot;, \
  4. &#39;./preproc/average_O2_A0_S0.txt&#39; w lp title &quot;O2 a[i]&quot; lc &quot;yellow&quot;, \
  5. &#39;./preproc/average_O2_A1_S0.txt&#39; w lp title &quot;O2 *(a + n)&quot; lc &quot;black&quot;, \
  6. &#39;./preproc/average_O2_A2_S0.txt&#39; w lp title &quot;O2 *p&quot; lc &quot;purple&quot;

huangapple
  • 本文由 发表于 2023年6月6日 08:31:30
  • 转载请务必保留本文链接:https://go.coder-hub.com/76410740.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定