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:

  1. plt = data(df) *
  2. mapping(
  3. :name,
  4. :grade;
  5. layout=:year) *
  6. visual(BarPlot)
  7. draw(plt)

Figure 54: AlgebraOfGraphics bar plot with automatic layout.

Figure 54: 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:

  1. plt = data(df) *
  2. mapping(:name, :grade; row=:year) *
  3. visual(BarPlot)
  4. draw(plt)

Figure 55: AlgebraOfGraphics bar plot with row layout.

Figure 55: AlgebraOfGraphics bar plot with row layout.

And, finally, an example with col:

  1. plt = data(df) *
  2. mapping(
  3. :name,
  4. :grade;
  5. col=:year) *
  6. visual(BarPlot)
  7. draw(plt)

Figure 56: AlgebraOfGraphics bar plot with column layout.

Figure 56: AlgebraOfGraphics bar plot with column layout.

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

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