Makie LaTeX fraction in y-axis label

Is there a way to allow the y-axis label in Makie be a fraction? Here is a minimal working example:

using CairoMakie

fig = Figure()
ax = Axis(fig[1,1])
lines!(ax, rand(5))
ax.ylabel = L"$\frac{a}{b}$"
save("file.pdf", fig)

I get the following error:

ERROR: AssertionError: length(positions) == length(colors)
Stacktrace:
  [1] draw_multi(primitive::LineSegments{Tuple{Vector{Point{2, Float32}}}}, ctx::Cairo.CairoContext, positions::Vector{Vec{2, Float32}}, colors::Vector{ColorTypes.RGBA{Float32}}, linewidths::Vector{Float32}, dash::Nothing)
    @ CairoMakie ~/.julia/packages/CairoMakie/Ry75I/src/primitives.jl:165
  [2] draw_atomic(scene::Scene, screen::CairoMakie.Screen{CairoMakie.PDF}, primitive::Union{LineSegments, Lines})
    @ CairoMakie ~/.julia/packages/CairoMakie/Ry75I/src/primitives.jl:63
  [3] draw_plot(scene::Scene, screen::CairoMakie.Screen{CairoMakie.PDF}, primitive::LineSegments{Tuple{Vector{Point{2, Float32}}}})
    @ CairoMakie ~/.julia/packages/CairoMakie/Ry75I/src/infrastructure.jl:131
  [4] cairo_draw(screen::CairoMakie.Screen{CairoMakie.PDF}, scene::Scene)
    @ CairoMakie ~/.julia/packages/CairoMakie/Ry75I/src/infrastructure.jl:51
  [5] backend_show(screen::CairoMakie.Screen{CairoMakie.PDF}, io::IOStream, #unused#::MIME{Symbol("application/pdf")}, scene::Scene)
    @ CairoMakie ~/.julia/packages/CairoMakie/Ry75I/src/display.jl:97
  [6] (::Makie.var"#1099#1100"{Module, Bool, Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}, Figure, MIME{Symbol("application/pdf")}, Scene})(io::IOStream)
    @ Makie ~/.julia/packages/Makie/uAmck/src/display.jl:325
  [7] open(::Makie.var"#1099#1100"{Module, Bool, Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}, Figure, MIME{Symbol("application/pdf")}, Scene}, ::String, ::Vararg{String}; kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
    @ Base ./io.jl:395
  [8] open
    @ ./io.jl:392 [inlined]
  [9] save(file::FileIO.File{FileIO.DataFormat{:PDF}, String}, fig::Figure; resolution::Tuple{Int64, Int64}, backend::Module, update::Bool, screen_config::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
    @ Makie ~/.julia/packages/Makie/uAmck/src/display.jl:319
 [10] save(file::FileIO.File{FileIO.DataFormat{:PDF}, String}, fig::Figure)
    @ Makie ~/.julia/packages/Makie/uAmck/src/display.jl:297
 [11] save(filename::String, fig::Figure; args::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
    @ Makie ~/.julia/packages/Makie/uAmck/src/display.jl:294
 [12] save(filename::String, fig::Figure)
    @ Makie ~/.julia/packages/Makie/uAmck/src/display.jl:291
 [13] top-level scope
    @ REPL[17]:1

I think for LaTeX strings you have to set them at axis creation. This should work:

using CairoMakie
using LaTeXStrings

fig = Figure()
ax = Axis(
    fig[1,1] ;
    ylabel = L"$\frac{a}{b}$" 
)
lines!(ax, rand(5))
save("file.pdf", fig)

It should also work the other way around, if not I’d consider that a bug. Please open an issue if you have time :slight_smile: