MakieOrg / Makie.jl

Interactive data visualizations and plotting in Julia
https://docs.makie.org/stable
MIT License
2.41k stars 313 forks source link

GLMakie zoom! is undone upon save, even if update_cam! used #3647

Open ahbarnett opened 8 months ago

ahbarnett commented 8 months ago

In fresh env:

julia> n=1000; f,a,p = scatter(rand(n),rand(n),rand(n),markersize=10)
julia> save("test.png",f)
julia> zoom!(a.scene,0.5)
julia> save("test2.png",f)

Results of two outputs (no zoom applied): test test2

The save operation (or even just replotting via f) undoes the zoom. Adding the recommended update_cam!(a.scene,cameracontrols(a.scene)) after the zoom has no effect :( I recently found this old discourse https://discourse.julialang.org/t/zoom-in-glmakie-3d-plot-then-save/65745/10 explaining to use save("test2.png",f;update=false) which does work. Could this crucial workaround be added to the Troubleshooting and/or docs on zoom?

Thanks! Alex

(jl_7Xk9Y1) pkg> st
Status `/tmp/jl_7Xk9Y1/Project.toml`
  [13f3f980] CairoMakie v0.11.8
  [e9467ef8] GLMakie v0.9.8
  [ee78f7c6] Makie v0.20.7

julia> versioninfo()
Julia Version 1.10.0
Commit 3120989f39b (2023-12-25 18:01 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: Linux (x86_64-linux-gnu)
  CPU: 16 × AMD Ryzen 7 5700U with Radeon Graphics
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-15.0.7 (ORCJIT, znver2)
  Threads: 23 on 16 virtual cores
Environment:
  LD_LIBRARY_PATH = :/usr/local/lib/:/home/alex/lib/:/usr/local/lib/:/home/alex/lib/
  JULIA_NUM_THREADS = 16
asinghvi17 commented 8 months ago

ah, could you post where in the docs you found that? It is pretty outdated and the update=false syntax is the correct way forward.

Thanks for catching this!

ahbarnett commented 8 months ago

Looking at https://docs.makie.org/stable/explanations/scenes/ https://docs.makie.org/stable/explanations/cameras/ I don't see anything about update=false. It would be great to add this to the examples and docs.

Eg, latter page has:

_zoom!(scene, zoom_step) will change the zoom level of the scene without translating or rotating the scene. zoom_step applies multiplicatively to cam.zoom_mult which is used as a multiplier to the fov (perspective projection) or width and height (orthographic projection). ... Often, when modifying the Scene, the camera can get "out of sync" with the Scene. To fix this, you can call the updatecam! function on the Scene.

I also in CairoMakie can't get the zoom! or update_cam! to affect anything in the screen or saved PNG, so am stuck... should I post a separate issue?