Closed jfb-h closed 2 months ago
Thanks for reporting this - it's another problem (similar to https://github.com/TidierOrg/TidierPlots.jl/issues/86) that is downstream from the "ad hoc" way I've handled the idea of "grouping" so far in the package. Hoping to have a fix for this on the way to 0.8.0
I have a MWE of grouping that may be useful. I'm not sure how it's being handled in TidierPlots (somewhere in draw.jl
?).
using DataFrames, ColorSchemes, CairoMakie
import Makie.SpecAPI as S
df = DataFrame(
a = rand(20),
b = rand(20),
c = rand(["L", "H"], 20),
d = rand(["A", "B"], 20),
)
group_df = groupby(df, [:c, :d])
palette = ColorSchemes.tab10
ax = S.Axis()
for (i, key) in enumerate(keys(group_df))
s = S.Lines(group_df[key].a, group_df[key].b, color = palette[i])
push!(ax, s)
end
layout_spec = S.GridLayout(ax)
plot(layout_spec)
It seems like the way to do grouping in Makie is to make multiple plot specs.
Thanks @adknudson - this was essentially how I was imagining this would be fixed, but helpful to have a MWE. I added support for geoms that return multiple PlotSpecs when I was fixing geom_smooth
(just need to have them return a Vector{PlotSpec}
and they should draw automatically). All we need to do is have geoms conditionally return a vector of plotspecs when appropriate and this should work
This is working for geom_path
in a dev branch:
geom_line
isn't currently cooperating - the sort is conflicting with the grouping. Should be fixed soon!
geom_line
fixed - will merge soon
If you plot different traces, the start of each trace gets connected to the next. Here's a reproducer: