Bar plots

### 20.1.14 Bar plots

The bar_plot or barplot command draws bar plots.

- bar_plot takes one mandatory argument and up to three optional arguments:
  - M, a matrix, where each row consists of a label followed by one or more values. If the labels are followed by more than one value, then the corresponding elements in the first row need to be identifiers or strings.
  - Optionally, color=col, where col is a color object or a list of color objects (see Section 19.1.3). By default, col=black.
  - Optionally, barwidth, a real number in ⟨ 0,1] which specifies the width of bars (by default, barwidth=0.75).
  - Optionally, axes, the symbol specifying that usual axes should be drawn, which is useful if you want to combine the output with other graphic objects.
- bar_plot(M ⟨,color=col,barwidth,axes ⟩) draws a bar graph with a bar for each label, whose height is given by the corresponding value. If M is a two-column matrix, then the first column can be numbers specifying bar base midpoints. If the matrix has more than two columns, then there will be a bar plot for each column of values. If col is a color object, then the bars are filled with the specified color. If col is a list of colors, then the fill color cycles through the list for bars from left to right (each group of bars is colored by using the same colors).

#### Examples

bar_plot([["France",6],["Germany",12],["Switzerland",5]],color=navy,0.618)

bar_plot([[2,"*First group*","*Second group*"], ["A",2,5],["B",5,6],["C",6,6]],color=[teal,olive,gold])

To specify the midpoints of bar bases, the first argument must be a list of pairs [midpoint,height]. For example:

barplot([[1,4],[3,5],[4,2]],color=orange)

Note that usual axes are automatically drawn in this case.