AoG with_theme

using AlgebraOfGraphics, CategoricalArrays, CairoMakie

let n = 100
k = 13
d = data((x=rand(n), y=rand(n), c=rand(CategoricalArray(1:k, ordered=true), n)))
v = visual(Scatter)
m = mapping(:x, :y, color=:c)
spec = d * v * m
p = draw(spec, palettes=(; color=collect(cgrad(:cividis, k, categorical=true))))
with_theme(theme_ggplot2()) do 
    p.figure
end
end

The code requests the ggplot2 theme, but it doesn’t work: For example, the background isn’t gray.

I think the theme must be in effect before draw is called, that’s when the defaults are populated

1 Like