Commands for plotting in Gnuplot

Here are a set of commands that you might find useful for plotting your data and drawing the line obtained from least square fit. Please look into the gnuplot manual or use "help" inside gnuplot to learn about the different options of plot, set, etc.


# To PLOT A SET OF DATA POINTS
# ============================
# Tell gnuplot to write the output into a postscript file
set terminal postscript portrait enhanced

# Tell gnupolot what is the output file name
set out "myplot_file_name.ps"

# Tell gnuplot to plot your data in the file "mydata.dat"
# with range of 0-100 on both the axes
plot [0:100] [0:100] 'mydata.dat'

# Now you have the plot in "myplot_file_name.ps"

# TO PLOT A FUNCTION
# ==================
# To define a (linear) function
f(x) = a * x + b

# To set some values for variables
a = 0.953
b = 0.538

# To set the title and to label the axes
set title "My Linear Function Plot"
set xlabel "X axis"
set ylabel "Y axis"

# Tell gnupolot what is the output file name
set out "myfunction_plot_file_name.ps"

# Tell gnuplot to plot a function
plot [0:100][0:100] f(x)

# Now you have the plot in "myfunction_plot_file_name.ps"