gnuplot : plotting data from multiple input files in a single graph

后端 未结 3 2141
面向向阳花
面向向阳花 2020-12-07 15:45

I am trying to plot a graph using gnuplot. I have six text files. Each text file contains two columns. The first column represents time in seconds (a floating point number).

相关标签:
3条回答
  • 2020-12-07 16:03

    replot is another way to get multiple plots at once:

    plot file1.data
    replot file2.data
    
    0 讨论(0)
  • 2020-12-07 16:04

    You're so close!

    Change

    plot "print_1012720" using 1:2 title "Flow 1", \
    plot "print_1058167" using 1:2 title "Flow 2", \
    plot "print_193548"  using 1:2 title "Flow 3", \ 
    plot "print_401125"  using 1:2 title "Flow 4", \
    plot "print_401275"  using 1:2 title "Flow 5", \
    plot "print_401276"  using 1:2 title "Flow 6"
    

    to

    plot "print_1012720" using 1:2 title "Flow 1", \
         "print_1058167" using 1:2 title "Flow 2", \
         "print_193548"  using 1:2 title "Flow 3", \ 
         "print_401125"  using 1:2 title "Flow 4", \
         "print_401275"  using 1:2 title "Flow 5", \
         "print_401276"  using 1:2 title "Flow 6"
    

    The error arises because gnuplot is trying to interpret the word "plot" as the filename to plot, but you haven't assigned any strings to a variable named "plot" (which is good – that would be super confusing).

    0 讨论(0)
  • 2020-12-07 16:07

    You may find that gnuplot's for loops are useful in this case, if you adjust your filenames or graph titles appropriately.

    e.g.

    filenames = "first second third fourth fifth"
    plot for [file in filenames] file."dat" using 1:2 with lines
    

    and

    filename(n) = sprintf("file_%d", n)
    plot for [i=1:10] filename(i) using 1:2 with lines
    
    0 讨论(0)
提交回复
热议问题