3.6.1 Basic Operation

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

 
plot 'datafile' with boxes

Horizontally, the interfaces between the bars are, by default, at the midpoints along the $x$-axis between the specified datapoints (see, for example, Panel (a) of Figure 3.5). 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$-coordinates, 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 Panel (c) of Figure 3.5.

\includegraphics{examples/eps/ex_barchart2.eps}
Figure 3.5: A gallery of different bar chart styles which PyXPlot can produce. See the text for more details.

Having set a fixed box width, the default automatic width mode 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 a column of the input datafile. For this, the wboxes plot style should be used:

 
plot 'datafile' using 1:2:3 with wboxes

This plot style expects three columns of data to be specified: the $x$- and $y$-coordinates of each bar, and the width in the third column. Panel (b) of Figure 3.5 shows an example of this plot style in use.

By default, the bars all 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, that may be achieved with the set boxfrom command, for example:

 
set boxfrom 5

All of the bars would then originate from the line $y=5$. Panel (f) of Figure 3.6 shows the kind of effect that is achieved; for comparison, panel (b) of the same figure shows the same bar chart with the boxes starting from their default position at $y=0$.

\includegraphics{examples/eps/ex_barchart1.eps}
Figure 3.6: A second gallery of different bar chart styles which PyXPlot can produce. See the text for more details.

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

 
plot 'datafile' with boxes fillcolour blue
plot 'datafile' with boxes fc 4

Panels (c) and (d) of Figure 3.5 demonstrate the use of filled bars.

Finally, the impulses plot style, as in gnuplot, produces bars of zero width; see Panel (e) of Figure 3.6 for an example.