7.2 Layouts

AlgebraOfGraphics.jl supports layouts with plots in multiple rows and columns, also known as faceting. These are specified using the keywords arguments layout, row and col inside mapping. If you use layout, AlgebraOfGraphics.jl will try to use the best combinations of rows and columns to layout the visualization:

plt = data(df) *
    mapping(
        :name,
        :grade;
        layout=:year) *
    visual(BarPlot)
draw(plt)
Figure 52: AlgebraOfGraphics bar plot with automatic layout.

However, you can override that by using either row or col for mutiple row or multiple columns layouts, respectively. Here’s an example with row:

plt = data(df) *
    mapping(:name, :grade; row=:year) *
    visual(BarPlot)
draw(plt)
Figure 53: AlgebraOfGraphics bar plot with row layout.

And, finally, an example with col:

plt = data(df) *
    mapping(
        :name,
        :grade;
        col=:year) *
    visual(BarPlot)
draw(plt)
Figure 54: AlgebraOfGraphics bar plot with column layout.

NOTE: You use both row and col one for each categorical variable.



Support this project
CC BY-NC-SA 4.0 Jose Storopoli, Rik Huijzer, Lazaro Alonso