2.7 Data Styles

By default, data from files are plotted with points, and functions are plotted with lines. However, either kinds of data can be plotted in a variety of ways. To plot a function with points, for example, the following syntax is usedNote that when a plot command contains both using/every modifiers, and the with modifier, the latter must come last.:

plot sin(x) with points

The number of points displayed (i.e. the number of samples of the function) can be set as follows:

set samples 100

Likewise, datafiles can be plotted with lines:

plot 'datafile' with lines

A variety of other styles are available. linespoints combines both the points and lines styles, drawing lines through points. Errorbars can also be drawn, as follows:

plot 'datafile' with yerrorbars

In this case, three columns of data need to be specified: the $x$- and $y$-coordinates of each datapoint, plus the size of the vertical errorbar on that datapoint. By default, the first three columns of the datafile are used, but once again (see Section 2.5), the using modifier can be used:

plot 'datafile' using 2:3:7 with yerrorbars

More details of the errorbars plot style can be found in Section 3.3.5. Other plots styles supported by PyXPlot are listed in Section 2.11, and their details can be found in many gnuplot tutorials. Bar charts will be discussed further in Section 3.6.

The modifiers “pointtype and “linetype, which can be abbreviated to “pt” and “lt” respectively, can also be placed after the with modifier. Each should be followed by an integer. The former specifies what shape of points should be used to plot the dataset, and the latter whether a line should be continuous, dotted, dash-dotted, etc. Different integers correspond to different styles.

The default plotting style referred to above can also be changed. For example:

set style data lines

The default style for plotting data from files is then changed to lines. Similarly the “set style function command changes the default style for plotting functions.