1

I want a plotting script that will plot multiple graphs on the same plot where the values of my data have the same x coordinate. This will show the differences of each variable in the plot. I tried to plot using spreadsheet, but the plots are not clearly identifiable each other. My data looks like:

x y1 y2 y3 y4 

1 10 25 28 30 
2 20 15 40 20 
3 10 10 30 20 
4 2 5 15 30    
. . . . 
  • 1
    Have a look at gnuplot, it has a great manual. – Marco Aug 29 '13 at 9:02
4

Assuming that you have all the data in a file named data.txt, the a typical GnuPlot script would contain:

# Set the output file type
set terminal postscript eps enhanced color solid colortext 9
# Set the output file name
set output 'multiple_plots.eps'

# Now plot the data with lines and points
plot 'data.txt' using 1:2 w lp title 'y1', \
     '' using 1:3 w lp title 'y2', \
     '' using 1:4 w lp title 'y3', \
     '' using 1:4 w lp title 'y4'

You can save the above code in a file say, plot.gp, and execute it with GnuPlot as:

gnuplot plot.gp

Please refer to the GnuPlot website for further details and a lot of demo scripts.

  • your script works great. I want the lines to be smooth with colors only in the legend and in the plot. Now it has box, stars with the color. Can you let me know how to remove those things? – AiB Aug 29 '13 at 19:42
  • 1
    So, you want only the lines? In the above code replace w lp with w l. This indicates that the plots should be done only with lines; w is the abbreviation for "with", and l is the abbreviation for "lines". – Barun Aug 29 '13 at 19:57
  • Thank you very much!! Now the plots look as I wanted for presentation. Awesome!! – AiB Aug 29 '13 at 21:14
  • @Abraham Glad to hear that! Also, please look at the site mentioned in the answer for many other different plot types and features. – Barun Aug 30 '13 at 5:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.