1
#!/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.

2
  • Welcome to StackOverflow! Are you talking about 6 graphs in 6 coordinate systems or 6 lines in 1 coordinate system? Or the latter in other words: should these line graphs share the same x- and y-axes? Commented Jun 6, 2023 at 7:18
  • I need 6 lines in one coordinate system, they should share the same axes. Commented Jun 6, 2023 at 9:44

2 Answers 2

0

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).

Sign up to request clarification or add additional context in comments.

1 Comment

I need 6 lines in one coordinate system, they should share the same axes.
0

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"

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.