Plotting Functions

The 2-D plotting command in gnuplot is called plot!  It operates on a datafile or specified function and has many options. You can plot a function just by typing something like
	plot sin(x)
Several functions may be plotted on the same graph by separating them with commas, e.g.
	plot sin(x), cos(x)
All the C library functions are recognized, and you can also define your own, e.g.
	f(x) = x*x*sin(pi*x)
	plot f(x)
(the value pi is built in). The x-range of the graph is set by gnuplot by default. Use
	plot [-2*pi:4*pi] sin(x)
to set it yourself. (Note that gnuplot will evaluate arithmetic expressions it encounters.) Alternatively, use the command
	set xrange [-2*pi:4*pi]
before the plot command to accomplish the same thing. The same applies for yrange. To restore the default range, use
	set xrange restore

To increase the resolution of the plot, use

	set sample <interval>
The default interval is 100; increasing the number gives a smoother graph.

Some other useful commands in this context are

plot f(x) with lines/points
Plot lines (the default) / isolated points.

set polar
Work in polar coordinates. The dummy variable in the plot command becomes (by default) t (for theta?). Use set nopolar to reverse this.

Numerous line and point styles are available, as described here.