Makie xlims!

How do I make this work… I have essentially tried everything for the last twenty minutes

?? = lines(x, y, z, linewidth=0.5, show_axis=false)
xlims!(??, 1.05,1.95)
ylims!(??, 1.05,1.95)

:smiley: I did have the same problem the other day.
A solution here:

Makie limits in a 3D scene - Domains / Visualization - JuliaLang

Although, I don’t like this approach. I think it will be better to be able to define the x,y,z limits instead of the axis from origin to width.

fig = lines(x, y, z, linewidth=0.5, show_axis=false)
xlims!(fig.axis.scene, 1.05,1.95)
ylims!(fig.axis.scene, 1.05,1.95)

Seems like an oversight bug that fig.axis which is a LScene doesn’t work with the limit functions. So, we need to get the underlying plain old Makie Scene.

If you are planning on doing layouts though, it might be better to use an explicit axis:

fig = Figure()
ax1 = fig[1, 1] = Axis(fig, ...)
lines!(ax1, x, y, z, linewidth=0.5, show_axis=false)
xlims!(ax1, 1.05, 1.95)
ylims!(ax1, 1.05, 1.95)

Yes, that confused and frustrated me



I think the problem is that LScene is not a 3D axis per se, we just currently use it as a workaround to have the old 3D plots available in layouts. As I showed on Slack, I think we need a reworked 3D axis anyway to make the look more streamlined with the 2D version. The key part here is to understand LScene is just a “dumb” layout wrapper for Scene, which is the real thing you need to manipulate. Axis on the other hand never has you modify the underlying Scene yourself. That’s the reason why LScene doesn’t have the helper functions defined

1 Like

I don’t think this got answered in this thread - is there currently a workaround way to set limits for an LScene?

just follow something like in here:

f = Figure()
l = LScene(f[1, 1], scenekw = (; limits=Rect3f(Vec3f(0,0,0),Vec3f(1.5, 1.5, 2.5))))
meshscatter!(l, rand(Point3f, 10); color = :blue)
meshscatter!(l, rand(Point3f, 10); color = :red)