Changing line color Theme in CairoMakie and GLMakie

I’m trying to define a custom plotting theme in Makie.jl. I want to remove the default color cycle for Lines and have black be the default color. I’m not sure if my syntax is correct, but it works in CairoMakie. But, when I activate the GLMakie backend and use display(), I get the following error:

ERROR: MethodError: no method matching gl_convert(::Symbol)

I’ve tried a few combinations for where to put cycle = nothing and linecolor = :black, but I still get stuck. I’m referencing the Cycles section of the Theming documentation.

(The reason I want to do this theme is that I want just the shape of a function to import into Affinity Designer and use that to fill in colors, etc. as part of a project.)

Code:

function theme_af()
    Theme(
        backgroundcolor = :transparent,
        Lines = (cycle = nothing, linecolor = :black),

        Axis = (
            backgroundcolor = :transparent,
            xgridvisible = false,
            ygridvisible = false,
            xminorgridvisible = false,
            yminorgridvisible = false,
            leftspinevisible = false,
            rightspinevisible = false,
            bottomspinevisible = false,
            topspinevisible = false,
            xminorticksvisible = false,
            yminorticksvisible = false,
            xticksvisible = false,
            yticksvisible = false,
            xticklabelsvisible = false,
            yticklabelsvisible = false,
        ),
)
end

set_theme!(theme_af())

f, ax, l = lines(1..10, sin)
display(f)

When you group it under Lines it’s just color not linecolor. Linecolor is a theme “global” so to speak which Line inherits its color setting from by default.

Thank you. Relatedly, I notice another difference that I can’t figure out. In the same example, with the first backgroundcolor set to :transparent, the plot is not visible when using GLMakie (Changing it to :white or some other color makes it visible again). But in CairoMakie, I see the plot and the grayed-out transparent background as expected. Am I doing something wrong here, too? I’m assuming the figure backgroundcolor is different from the Axis block backgroundcolor.

GLMakie cannot do a transparent figure background, the buffer doesn’t hold RGBAs (the A is used for the stencil buffer I think?)

1 Like

That makes sense. Thank you!

It’s too bad but it seemed it would be nontrivial to change without major pipeline refactoring.

Seems like you spent some time going down that path.

Not me personally, but @ffreyer and @sdanisch

1 Like