Grouping for color or markers in CairoMakie

is there a way to groupby a dataframe column passed into color or marker such that each group gets a unique element? or does this have to be done as different scatter! calls for each group

ccf = DataFrame(a = 1:4, 
                b = 1:4, 
                c = ["low", "low", "high", "high"])

fig = default_figure()
ax2 = fig[1, 1] = Axis(fig, title = "test")
scat1 = scatter!(ax2, ccf.a,ccf.b, color= :red)
fig

Are you looking for something like this:

using DataFrames, GLMakie, ColorSchemes

ccf = DataFrame(a = 1:4, 
                b = 1:4, 
                c = ["low", "low", "high", "high"])

palette = ColorSchemes.tab10.colors

color_indices = groupindices(groupby(ccf, :c))
scatter(ccf.a, ccf.b, color=palette[color_indices])

yes. Thank you.

is there a collection of marker’s that can be accessed like the color palette?

marker, like color, can also be a vector rather than a scalar, so

marker_indices = groupindices(groupby(ccf, :c))
marker = ['↓', '↑']
scatter(ccf.a, ccf.b, marker = marker[marker_indices])

should work. Though there doesn’t seem to be a “marker palette”-like collection.

see here:

2 Likes

And it looks like the default list is in AbstractPlotting.default_palettes.marker.

2 Likes