0% found this document useful (0 votes)
165 views

Gnuplot Cheat Sheet: Generic Plot-Tweaking

This document provides a cheat sheet on using GNUPlot, an open source graphing utility. It outlines commands for basic plotting, 2D and 3D plotting, parametric plots, data files, fitting, exporting plots, and setting plot styles and labels. Key commands include plot, splot, set samples, set term, and set output for generating and customizing graphs from functions and data files.

Uploaded by

Gustavo Paredes
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
165 views

Gnuplot Cheat Sheet: Generic Plot-Tweaking

This document provides a cheat sheet on using GNUPlot, an open source graphing utility. It outlines commands for basic plotting, 2D and 3D plotting, parametric plots, data files, fitting, exporting plots, and setting plot styles and labels. Key commands include plot, splot, set samples, set term, and set output for generating and customizing graphs from functions and data files.

Uploaded by

Gustavo Paredes
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

GNUPlot Cheat Sheet

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

• Enabling Parametric Mode: set param (Use unset param to disable)


• Enabling Polar Mode: set polar (Use unset polar to disable)
• Parametric plots: plot [xfunc(t)], [yfunc(t)] Eg: plot cos(t), sin(t)

• 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

• Nicely colored plots: splot f(x,y) with pm3d


• Samples: set isosamples [nsamples]
• Parametric mode: set param. u and v are the parameters.
• Parametric plots: splot x(u,v), y(u,v), z(u,v) Eg: splot sin(u)*cos(v), sin(u)*sin(v), cos(v) title
"2-Sphere"
• Contours: set contour
• Contour Levels: set cntrparam levels [nlevels]

You might also like