Geom.subplot_grid

Draw multiple subplots in a grid organized by one or two categorial vectors.

Aesthetics

the subplots. Defaults to false. If true, scales are set appropriately for individual subplots.

the subplots. Defaults to false. If true, scales are set appropriately for individual subplots.

One or both of xgroup or ygroup must be bound. If only one, a single column or row of subplots is drawn, if both, a grid.

Arguments

Geom.subplot_grid(elements::Gadfly.ElementOrFunction...)

Unlike most geometries, Geom.subplot_grid is typically passed one or more parameters. The constructor works for the most part like the layer function. Arbitrary plot elements may be passed, while aesthetic bindings are inherited from the parent plot.

Examples

set_default_plot_size(20cm, 7.5cm)
plot(dataset("datasets", "OrchardSprays"),
     xgroup="Treatment", x="ColPos", y="RowPos", color="Decrease",
     Geom.subplot_grid(Geom.point))
ColPos by Treatment 1 100 150 50 Decrease A C F G H B E D 0 2 4 6 8 0 2 4 6 8 0 2 4 6 8 0 2 4 6 8 0 2 4 6 8 0 2 4 6 8 0 2 4 6 8 0 2 4 6 8 0 2 4 6 8 RowPos
set_default_plot_size(14cm, 25cm)
plot(dataset("vcd", "Suicide"), xgroup="Sex", ygroup="Method", x="Age", y="Freq",
     Geom.subplot_grid(Geom.bar))
Age by Sex female male 0 50 100 0 50 100 0 500 1000 1500 other 0 500 1000 1500 jump 0 500 1000 1500 knife 0 500 1000 1500 gun 0 500 1000 1500 drown 0 500 1000 1500 hang 0 500 1000 1500 toxicgas 0 500 1000 1500 cookgas 0 500 1000 1500 poison Freq by Method

Free/fixed scales:

using RDatasets # hid
using DataFrames
set_default_plot_size(8cm, 12cm)

widedf = DataFrame(x = collect(1:10), var1 = collect(1:10), var2 = collect(1:10).^2)
longdf = stack(widedf, [:var1, :var2])

Default behavior is for the axes' scales to be fixed across the subplots:

plot(longdf, ygroup="variable", x="x", y="value", Geom.subplot_grid(Geom.point))
x 0.0 2.5 5.0 7.5 10.0 0 50 100 var2 0 50 100 var1 value by variable

We can change this default behavior where appropriate:

plot(longdf, ygroup="variable", x="x", y="value", Geom.subplot_grid(Geom.point, free_y_axis=true))
x 0.0 2.5 5.0 7.5 10.0 0 50 100 var2 0.0 2.5 5.0 7.5 10.0 var1 value by variable