Quick Guide to GNUPlot - Example, Superscript, Subscript, Overbar, Underbar, Greek Symbols
Posted on Saturday, January 07, 2006 at 4:20 PM by Malcolm
Quick Guide to GNUPlot
See also
Setup
To plot a graph X , create two files, "plot.dat" and "plot.txt":"data.txt" contains the columns of values to be plotted.
"plot.txt" contains the commands for gnuplot to plot the graph.
"plot.eps" contains the EPS output (PDF version here, converted using eps2pdf).
To generate the graph, run "gnuplot plot.txt > plot.eps".
Insert Superscript, Subscript and Greek Symbols
Insert "enhance postscript" in "plot.txt""set terminal postscript eps enhance 16"
Change 16 to whatever font size desired.
Superscript and Subscript
- To have xyz as subscript of P, use "P_{xyz}"
- To have xyz as superscript of P, use "P^{xyz}"
- Note the use of open and close braces to group a set of characters
- Although there isn't any postscript option to specify overbar and underbar, a way to simulate them is to do the following:
- To have an overbar on the letter G, use "@^{\261}G" (short overbar) or "@^{\320}G" (long overbar)
- To have an underbar on the letter G, use "@_{\261}G" (short underbar) or "@_{\320}G" (long underbar)
- To have the symbol α (alpha), use "{/Symbol a}"
- To have the symbol π (pi), use "{/Symbol p}"
- To have the symbol λ (lambda), use "{/Symbol l}"
- See the file below for a complete list of other available symbols
Note that versions 3.5 or earlier do not support these postscript options
Placing Legend/Key at a specfic coordinate
- To move the keys to coordinate say (3,4), use "set key 3, 4"
Change the size of the plot points
- To change the size of the plot points to 2, use "set pointsize 2"
Set the size of the graph
- To change the size of the plot to 5 by 5, use "set size 5,5"
Set xlabel/ylabel
- To change the xlabel to "XLABEL", use " set xlabel "XLABEL" "
- To change the ylabel to "YLABEL", use " set xlabel "YLABEL" "
Remove mirror tickmark
- To remove mirror xtick marks, use "set xtics nomirror"
- To remove mirror ytick marks, use "set ytics nomirror"
Set the range of X and Y axes
- Example : "set xrange [0:50]"
- Example : "set yrange [0:100]"
Preset Tickmark on X axis
- To preset tickmark on x-axis, use "set xtics (10,100,1000,10000)"
- Note that this can be combined with the option "nomirror" too.
