Gadfly.jl
Gadfly.jl copied to clipboard
Stats in Geom.subplot_grid
In the main Gadfly plot, Stats and Geoms that are not in layers, are both pushed into a layer (which makes sense). This means the statistics
field of the main plot (p1.statistics
below) is actually obsolete.
p1 = plot(Stat.smooth, Geom.ribbon)
p1.statistics # StatisticElement[]
p1.layers[1].statistics # StatisticElement[Stat.smooth()]
p1.layers[1].geom # Geom.ribbon()
Geom.subplot_grid
has similar fields to the main plot. In subplot_grid
Geoms that are not in layers get pushed to a layer,
but Stats get pushed to the statistics
field of subplot_grid
(p2.statistics
below). This is problematic,
because the Stat and Geom don't have a clear association (this is worse when attempting to use multiple Stats/Geoms).
p2 = Geom.subplot_grid(Stat.smooth, Geom.ribbon)
p2.statistics # StatisticElement[Stat.smooth()]
p2.layers[1].statistics # StatisticElement[]
p2.layers[1].geom # Geom.ribbon()
The decoupling of the Stat/Geom makes it makes it unclear what the purpose of p2.statistics
is, leading to bad coding.
Do you propose then to remove p2.statistics
and push all stats to p2.layers[1].statistics
?
Not all stats to one layer, but to the appropriate layer, as happens in a plot
with multiple layers. I'm close to having a PR ready.
A reminder to test these 2 examples:
- https://discourse.julialang.org/t/how-to-make-geom-errorbar-work-with-geom-subplot-grid-in-gadfly-jl/80158/2
- https://discourse.julialang.org/t/how-to-make-stat-x-jitter-work-with-geom-subplot-grid/80152