Render 2d points with gnuplot to PNG

One of the easiest way to render some points with gnuplot is:

  1. write to fileย (eg points.txt) the points you want to render in simple text format, one line per point (x,y pairs, no tabs no commas etc)
  2. create a script with the code shown below (eg graph.gnuplot)
  3. run the script with gnuplot (eg gnuplot graph.gnuplot)
  4. Open the png file with a program of your choice.

point file sample:

10 10
20 20
30 30


script sample

set terminal png
set size ratio -1
set output "./graph.png"
plot \
"points1.txt" notitle with points pointsize 0.5 linecolor rgb "green",\
"points2.txt" notitle with points pointsize 0.5 linecolor rgb "yellow",\
"points3.txt" notitle with points pointsize 0.5 linecolor rgb "black"


execution example:

gnuplot graph.gnuplot

Advertisements