Gnuplot Cheat Sheet: Generic Plot-Tweaking
Gnuplot Cheat Sheet: Generic Plot-Tweaking
Generic Plot-tweaking
• Legend: set key [left|right] [box|nobox]. There are a lot more options which we are not specified here.
• Axis Labels: set xlabel "[x label]" etc.
• Plot Styles: plot [function] with [style]. Eg: plot sin(x) with impulses
• Line Types: plot [function] lt [line type number]. Eg: plot sin(x) lt 6
• Plot Title: plot [function] title "[title]"
2-D Plotting
• Basic plotting: plot [function]. Eg: plot sin(x)
• Setting number of Samples: set samples [samples]. Eg: set samples 50
• Real and imaginary parts: plot real([function]). Eg: plot real(sin(x)**besj0(x))
• Plotting data files: plot [file] using [xcol]:[ycol]. Eg: plot "foo.dat" using 1:2
• Spline fit: plot [file] using [xcol]:[ycol] smooth [method]. Eg: plot "foo.dat" using 1:2 smooth
csplines
• General nonlinear fitting: fit [function] [datafile] using [xcol]:[ycol]:[std. devn] via [params].
Eg: plot a*x+b "foo.dat" using 1:2 via a,b
• Vector fields: plot [datafile] using [x]:[y]:[dx]:[dy] Eg: plot "vectorfoo.dat" using 1:2:3:4
Exporting Plot
GNUPlot can export the plot into a file in a variety of formats.
• Setting export format / Terminal type: set term [termtype]. Try set term for a list.
• Setting output file: set output [file]
• Show output status: show output
3-D Plots
• Surface plots: splot f(x,y) Eg: splot [-pi:pi] [-pi:pi] cos(x)*cos(y) title "Ground State"
• Enabling / Disabling grid: set grid and unset grid