This is for a quick visual inspection of your job data output as XY plot. The XY data containing is read from the file data_input.dat
1 2 3 4 5 6 7 | 1.00 0.00000 2.00 0.74103 3.00 0.79751 .. .... .. .... |
1 2 3 4 | $ gnuplot > plot "data_input.dat" |
Now a scatter plot will pop up as a window. If you are logged into remote session with ssh, make sure you have forwarded the X. i.e. logged in with -X flag
1 2 3 | $ ssh -X yourhost |
Change it to line plot by adding ‘with lines’
1 2 3 4 | $ gnuplot > plot "data_input.dat" with lines |
Now for more advanced options:
1. To save the plot as png image, add set terminal png, set output “plot.png”
1 2 3 4 5 | set terminal png set output "plot.png" plot "data_input.dat" with lines |
Now the plot will be saved as ‘plot.png’ into working directory. You can open the image from terminal using eog (eye of gnome)
1 2 3 | $ eog plot.png |
2. To label the X and Y and plot grid, add set ylabel “RMS”, set xlabel “Time” and set grid
1 2 3 4 5 6 7 8 | set terminal png set output "plot.png" set ylabel "RMS" set xlabel "Time" set grid plot "data_input.dat" with lines |
3. If you want to plot 1st and 5th column in your data_input.dat, add ‘using 1:5’ in plot command
1 2 3 4 5 6 7 8 | set terminal png set output "plot.png" set ylabel "RMS" set xlabel "Time" set grid plot "data_input.dat" using 1:5 with lines |
4. To plot two data series in the same plot and label each line, add next series after a comma
1 2 3 4 5 6 7 8 | set terminal png set output "plot.png" set ylabel "RMS" set xlabel "Time" set grid plot "data_input.dat" using 1:2 with lines title 'data-1', "data_input.dat" using 1:5 with lines title 'data-5' |
To plot many series, it’s convenient to use the line continuation character, “\” .
1 2 3 4 5 6 7 8 9 10 | set terminal png set output "plot.png" set ylabel "RMS" set xlabel "Time" set grid plot "data_input.dat" using 1:2 with lines title 'data-1', \ "data_input.dat" using 1:3 with lines title 'data-3' \ "data_input.dat" using 1:5 with lines title 'data-5' \ |
5. Running it from a script, Put all these commands into a script and run if you have to run them several times
1 2 3 4 5 6 7 8 9 10 11 12 | #!/usr/bin/gnuplot reset set terminal png set output "plot.png" set ylabel "RMS" set xlabel "Time" set grid plot "data_input.dat" using 1:2 with lines title 'data-1', \ "data_input.dat" using 1:3 with lines title 'data-3' \ "data_input.dat" using 1:5 with lines title 'data-5' \ |
matplotlib is another even better option for advanced graph creation
More examples:
1. Gnuplot 4.2 Tutorial
2. Plot your graphs with command line gnuplot
3. Data visualization tools for Linux