英文:
Gnuplot replot command doesn't build a plot
问题
#!/usr/bin/gnuplot -persist
reset
NO_ANIMATION = 1
set terminal png size 1920, 1080
set output 'graph1.png'
set size 1, 1
set key left box
set title "Piecewise Linear Plot"
set xlabel "Number of Elements, Count"
set ylabel "Time, µs"
set grid
plot './preproc/average_O0_A0_S0.txt' with linespoints title 'O0 a[i]' lc "red"
replot './preproc/average_O0_A1_S0.txt' with linespoints title 'O0 *(a + n)' lc "blue"
replot './preproc/average_O0_A2_S0.txt' with linespoints title "O0 *p" lc "green"
replot './preproc/average_O2_A0_S0.txt' with linespoints title "O2 a[i]" lc "yellow"
replot './preproc/average_O2_A1_S0.txt' with linespoints title "O2 *(a + n)" lc "black"
replot './preproc/average_O2_A2_S0.txt' with linespoints title "O2 *p" lc "purple"
英文:
#!/usr/bin/gnuplot -persist
reset
NO_ANIMATION = 1
set terminal png size 1920, 1080
set output 'graph1.png'
set size 1, 1
set key left box
set title "Кусочно-линейный график"
set xlabel "Количество элементов, шт"
set ylabel "Время, мкс"
set grid
plot './preproc/average_O0_A0_S0.txt' with linespoints title 'O0 a[i]' lc "red"
replot './preproc/average_O0_A1_S0.txt' with linespoints title 'O0 *(a + n)' lc "blue"
replot './preproc/average_O0_A2_S0.txt' with linespoints title "O0 *p" lc "green"
replot './preproc/average_O2_A0_S0.txt' with linespoints title "O2 a[i]" lc "yellow"
replot './preproc/average_O2_A1_S0.txt' with linespoints title "O2 *(a + n)" lc "black"
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
:
语法:
plot {<ranges>} <plot-element> {, <plot-element>, <plot-element>}
此外,这里还有\
用于继续下一行(提高可读性)。
查看PDF手册中的“Introduction”:
通过在每一行的末尾添加反斜杠(
\
),可以使命令跨越多行输入。反斜杠必须是每一行的最后一个字符。其效果就好像反斜杠和换行符不存在一样。
plot './preproc/average_O0_A0_S0.txt' w lp title 'O0 a[i]' lc "red", \
'./preproc/average_O0_A1_S0.txt' w lp title 'O0 *(a + n)' lc "blue", \
'./preproc/average_O0_A2_S0.txt' w lp title "O0 *p" lc "green", \
'./preproc/average_O2_A0_S0.txt' w lp title "O2 a[i]" lc "yellow", \
'./preproc/average_O2_A1_S0.txt' w lp title "O2 *(a + n)" lc "black", \
'./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.
plot './preproc/average_O0_A0_S0.txt' w lp title 'O0 a[i]' lc "red", \
'./preproc/average_O0_A1_S0.txt' w lp title 'O0 *(a + n)' lc "blue", \
'./preproc/average_O0_A2_S0.txt' w lp title "O0 *p" lc "green", \
'./preproc/average_O2_A0_S0.txt' w lp title "O2 a[i]" lc "yellow", \
'./preproc/average_O2_A1_S0.txt' w lp title "O2 *(a + n)" lc "black", \
'./preproc/average_O2_A2_S0.txt' w lp title "O2 *p" lc "purple"
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论