LaTeX z-label in 3D Makie plot

I want to make a 3D surface plot in Makie, and I need the z-axis label to be formatted with \LaTeX. Whenever I add such a label, all the content in the plot disappears. For example, the following plot works without adding an L prefix to the z-label:

using CairoMakie
x = collect(-2:0.01:2) 
y = collect(-2:0.01:2)
Z = [1/(1+(x+im*y)^2) for y in y, x in x]
fig = Figure()
ax = Axis3(fig[1, 1], zlabel = "|1/(1+z^2)|")
surface!(ax, x, y, abs.(Z))
zlims!(ax, 0, 5)

Once I try and format the z-label into \LaTeX:

x = collect(-2:0.01:2) 
y = collect(-2:0.01:2)
Z = [1/(1+(x+im*y)^2) for y in y, x in x]
fig = Figure()
ax = Axis3(fig[1, 1], zlabel = L"|1/(1+z^2)|")
surface!(ax, x, y, abs.(Z))
zlims!(ax, 0, 5)

everything in the plot disappears.

Am I doing something wrong here, or is there a way around this?

1 Like

Hm if everything disappears could it be some bug with this particular latex expression? What about just L"x" just to make sure it’s not that

That also seems to break it, no latex expression I’ve tried seems to work. It also seems to only be for the z-axis label, e.g. the following works with a latex x-label:

using CairoMakie
x = collect(-2:0.01:2) 
y = collect(-2:0.01:2)
Z = [1/(1+(x+im*y)^2) for y in y, x in x]
fig = Figure()
ax = Axis3(fig[1, 1], zlabel = "z", xlabel = L"x")
surface!(ax, x, y, abs.(Z))
zlims!(ax, 0, 5)

Oh that sounds weird, I’ll have to take a look at t some point. Could you please file an issue with your example code?

1 Like

Done - I should have done that to start with but figured it was a mistake on my part. Thanks.