Plotting two-dimensional functions
A D V E R T I S E M E N T
Please read the section on
defining your own
functions if you intend to define your own functions.
The syntax of the plot command for a two-dimensional
function is as follows:
plot {ranges}
function {title
"title text"} {style}
If several plots are to be plotted, subsequent functions (or data plots) can be
specified, separated by commas. The optional sections are shown with braces.
Note that only one set of ranges can be specified, as the subsequent plots (or
data plots) use the same range. By omitting those optional sections, the
simplest plot only needs the function to be plotted, as shown:
plot sin(x)
Fine Tuning your Plots
When gnuplot creates a function plot, it samples 100 points of the function in
the specified range. You can adjust the number of points taken with the
set samples command. Note that plotting will take somewhat longer if
more points are specified. (You can also set it to something less than 100
points, as well.) Here is an example of two plots of the sinc function, with
different sampling rates:
sinc(x) = sin(pi * x) / (pi * x)
set samples 25; plot sinc(x)
set samples 500; plot sinc(x)
Many other options are available to let you change the plot's output. Other
available plot modes
Parametric Plots
Instead of using a single function to describe a curve, you can use the
set parametric command to set Gnuplot to use parametric curves.
When making these plots, you will need to specify two functions of the dummy
variable t, called f(t) and f(t). (To turn it off,
use set noparametric)
set parametric
plot cos(t * 3), sin(t * 2)
Polar Plots
Similar to the above setting, you can use the set polar
option to set the axes to use polar coordinates, rather than cartesian. For
polar plots, the x coordinate becomes theta and the y coordinate
becomes r or radius. (To turn it back to cartesian coordinates, use
set nopolar)
set polar
plot cos(2 * x)
|