# Zoom a \`CairoMakie\` mesh plot

**URL:** <https://discourse.julialang.org/t/zoom-a-cairomakie-mesh-plot/71739>\
**Category:** Visualization\
**Tags:** makie\
**Created:** [November 18, 2021, 7:20pm UTC](https://discourse.julialang.org/t/zoom-a-cairomakie-mesh-plot/71739 "2021-11-18T19:20:28Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![circonflexe](https://avatars.discourse-cdn.com/v4/letter/c/c57346/32.png) [@circonflexe](https://discourse.julialang.org/u/circonflexe)\
**Post date:** [November 18, 2021, 7:20pm UTC](https://discourse.julialang.org/t/zoom-a-cairomakie-mesh-plot/71739/1 "2021-11-18T19:20:28Z")

</div>

`CairoMakie` can do a 3d plot of a mesh; e.g.

```julia
using CairoMakie
save("mesh.png", plot([1. 0 0;0 1 0;0 0 1;0 0 0],[1 2 3;2 3 4]))

```

How is it possible to zoom such a picture? I tried calling `zoom!(m.figure.scene, [0,0,0],10.,false))`  
(where `m` is the result of the `plot` command above), but this does not change anything when saving the plot to a file.

---

<div class="post-metadata">

**Author:** ![bvrb](https://avatars.discourse-cdn.com/v4/letter/b/76d3ee/32.png) [@bvrb](https://discourse.julialang.org/u/bvrb)\
**Post date:** [November 18, 2021, 7:57pm UTC](https://discourse.julialang.org/t/zoom-a-cairomakie-mesh-plot/71739/2 "2021-11-18T19:57:37Z")

</div>

For zooming, it should be enough to call `zoom!(scene, zoom_step)` for your figure’s scene where it zooms in for values of `zoom_step` smaller than 1, and zooms out if greater than 1.

If you want to save the zoomed version of the plot to a file, you have to add `scene.center = false` before calling the `save` command, see: [Saving Makie plot as is on the screen? - #2 by sdanisch](https://discourse.julialang.org/t/saving-makie-plot-as-is-on-the-screen/24276/2)

---

<div class="post-metadata">

**Author:** ![circonflexe](https://avatars.discourse-cdn.com/v4/letter/c/c57346/32.png) [@circonflexe](https://discourse.julialang.org/u/circonflexe)\
**Post date:** [November 18, 2021, 8:57pm UTC](https://discourse.julialang.org/t/zoom-a-cairomakie-mesh-plot/71739/3 "2021-11-18T20:57:52Z")

</div>

```julia
ERROR: MethodError: no method matching zoom!(::Scene, ::Float64)
Closest candidates are:
  zoom!(::Any, ::Any, ::Any, ::Bool) at /home/jerome/.julia/packages/Makie/Riyar/src/camera/camera3d.jl:258
Stacktrace:
 [1] top-level scope
   @ REPL[20]:1

```

Maybe this works with a more recent version? I have Makie v0.14.2. Thanks for the pointer for `scene.center` though! I would never have guessed that.

---

<div class="post-metadata">

**Author:** ![ffreyer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ffreyer/32/21569_2.png) [@ffreyer](https://discourse.julialang.org/u/ffreyer)\
**Post date:** [November 18, 2021, 9:07pm UTC](https://discourse.julialang.org/t/zoom-a-cairomakie-mesh-plot/71739/4 "2021-11-18T21:07:12Z")

</div>

If you’re using an older version you may need to call `update_cam!(scene, cameracontrols(scene))` after calling zoom. Also you should be passing `ax.scene` rather than `fig.scene`.

---

<div class="post-metadata">

**Author:** ![bvrb](https://avatars.discourse-cdn.com/v4/letter/b/76d3ee/32.png) [@bvrb](https://discourse.julialang.org/u/bvrb)\
**Post date:** [November 19, 2021, 8:44am UTC](https://discourse.julialang.org/t/zoom-a-cairomakie-mesh-plot/71739/5 "2021-11-19T08:44:45Z")

</div>

Yes, you are right, that was introduced in newer versions. So the syntax you had in the first post should be fine then.
