4.2.1 Basic Operation

As in Gnuplot, bar charts and histograms can be produced using the boxes plot style:

 
plot 'data.dat' with boxes

Horizontally, the interfaces between the bars are, by default, at the midpoints along the $x$-axis between the specified data points (see, for example, Figure 4.1a). Alternatively, the widths of the bars may be set using the set boxwidth command. In this case, all of the bars will be centred upon their specified $x$-co-ordinates, and have total widths equalling that specified in the set boxwidth command. Consequently, there may be gaps between them, or they may overlap, as seen in Figure 4.1(b).

\includegraphics{examples/eps/ex_barchart2.eps}
Figure 4.1: A gallery of the various bar chart styles which PyXPlot can produce. See the text for more details. The script and data file used to produce this image are available on the PyXPlot website at http://www.pyxplot.org.uk/examples/Manual/04barchart2/.

Having set a fixed box width, the default behaviour of scaling box widths automatically may be restored either with the unset boxwidth command, or by setting the boxwidth to a negative width.

As a third alternative, it is also possible to specify different widths for each bar manually, in an additional column of the input data file. To achieve this behaviour, the wboxes plot style should be used:

 
plot 'data.dat' using 1:2:3 with wboxes

This plot style expects three columns of data to be provided: the $x$- and $y$-co-ordinates of each bar in the first two, and the width of the bars in the third. Figure 4.1(c) shows an example of this plot style in use.

By default, the bars originate from the line $y=0$, as is normal for a histogram. However, should it be desired for the bars to start from a different vertical point, this may be achieved by using the set boxfrom command, for example:

 
set boxfrom 5

In this case, all of the bars would now originate from the line $y=5$. Figure 4.2(1) shows the kind of effect that is achieved; for comparison, Figure 4.2(b) shows the same bar chart with the boxes starting from their default position of $y=0$.

\includegraphics{examples/eps/ex_barchart1.eps}
Figure 4.2: A second gallery of the various bar chart styles which PyXPlot can produce. See the text for more details. The script and data file used to produce this image are available on the PyXPlot website at http://www.pyxplot.org.uk/examples/Manual/03barchart1/.

The bars may be filled using the with fillcolour modifier, followed by the name of a colour:

 
plot 'data.dat' with boxes fillcolour blue
plot 'data.dat' with boxes fc 4

Figures 4.1(b) and (d) demonstrate the use of filled bars.

Finally, the impulses plot style, as in Gnuplot, produces bars of zero width; see Figure 4.2(c) for an example.