Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

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 help me the differences of each variable in the plot. I tried to plot using spreadsheet, but the plots are not clearly identifiable each other. I want you help me with the script to do my plot. 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    
. . . . 
share|improve this question
1  
Have a look at gnuplot, it has a great manual. –  Marco Aug 29 '13 at 9:02

1 Answer 1

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.

share|improve this answer
    
Thank you very much!! It works great! Awesome –  Abraham Aug 29 '13 at 17:57
    
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? –  Abraham 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!! –  Abraham 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

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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