# Makie aspect ratio 3D plot

**URL:** <https://discourse.julialang.org/t/makie-aspect-ratio-3d-plot/57705>\
**Category:** Visualization\
**Tags:** question, plotting, makie\
**Created:** [March 22, 2021, 12:23pm UTC](https://discourse.julialang.org/t/makie-aspect-ratio-3d-plot/57705 "2021-03-22T12:23:06Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![lazarusA](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lazarusa/32/6571_2.png) [@lazarusA](https://discourse.julialang.org/u/lazarusA)\
**Post date:** [March 22, 2021, 12:23pm UTC](https://discourse.julialang.org/t/makie-aspect-ratio-3d-plot/57705/1 "2021-03-22T12:23:06Z")

</div>

When plotting into an LScene and by using an Axis, the output figure is always rescaled into the data limits, making sometimes hard to see things, if one of the variables is too large or to low.  
MWE

```julia
using GLMakie
fig = Figure(resolution = (600, 400)) 
ax = LScene(fig, scenekw = (camera = cam3d!, show_axis =true))
sphere = surface!(ax, 4*rand(100,100), 2*rand(100,100), 0.1*rand(100,100), color = rand(100,100), 
    colormap = :hot, shading = false, transparency = true)
fig[1, 1] = ax
fig

```

![FigScales](https://global.discourse-cdn.com/julialang/original/3X/a/e/aef2d6558d9e68588a740c227ccdcaf94a54fa01.png)

In some cases is nice[like below], but not always [most cases I would say].  
 ![FigReScales](https://global.discourse-cdn.com/julialang/original/3X/c/e/ce8240e71409625c5ef60e1b9c3b95dbb6aa35b2.png)

I would like to be able to control the `aspect_ratio` in every direction, is that possible somehow?

related question: [Issues with JuliaPlots aspect ratio in 3d](https://discourse.julialang.org/t/issues-with-juliaplots-aspect-ratio-in-3d/28023)  
the zoom question there is also a problem in most of cases [a lot of white space].

---

<div class="post-metadata">

**Author:** ![rafael.guerra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafael.guerra/32/216610_2.png) [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)\
**Post date:** [March 22, 2021, 3:41pm UTC](https://discourse.julialang.org/t/makie-aspect-ratio-3d-plot/57705/2 "2021-03-22T15:41:02Z")

</div>

Given the range of input data along each axis, if one wants to scale the output independently by 1x, 2x and 40x for example, along x-, y- and z-axis, I think this works:

```julia
scene = Scene(resolution = (600, 400))
scale!(scene, 1, 2, 40)

```

---

<div class="post-metadata">

**Author:** ![Libbum](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/libbum/32/3935_2.png) [@Libbum](https://discourse.julialang.org/u/Libbum)\
**Post date:** [March 22, 2021, 4:16pm UTC](https://discourse.julialang.org/t/makie-aspect-ratio-3d-plot/57705/3 "2021-03-22T16:16:02Z")

</div>

For somewhat cubic plots regardless of limits in each direction, I usually do something like:

```julia
    lims = ((0, 100), (0, 4), (0, 150))
    xlims!(scene, lims[1])
    ylims!(scene, lims[2])
    zlims!(scene, lims[3])
    m = maximum(abs(x[2] - x[1]) for x in lims)
    a = [m / abs(x[2] - x[1]) for x in lims]
    scale!(scene, a...)

```

---

<div class="post-metadata">

**Author:** ![sdanisch](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sdanisch/32/1406_2.png) [@sdanisch](https://discourse.julialang.org/u/sdanisch)\
**Post date:** [March 22, 2021, 4:17pm UTC](https://discourse.julialang.org/t/makie-aspect-ratio-3d-plot/57705/4 "2021-03-22T16:17:24Z")

</div>

[https://github.com/JuliaPlots/AbstractPlotting.jl/pull/649](https://github.com/JuliaPlots/AbstractPlotting.jl/pull/649)  
Should give some real improvements for this situation!

---

<div class="post-metadata">

**Author:** ![lazarusA](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lazarusa/32/6571_2.png) [@lazarusA](https://discourse.julialang.org/u/lazarusA)\
**Post date:** [March 22, 2021, 4:56pm UTC](https://discourse.julialang.org/t/makie-aspect-ratio-3d-plot/57705/5 "2021-03-22T16:56:09Z")

</div>

in the example above using `scale!(ax.scene, 100, 100, 2055)` seems to give good aspect\_ratios, however once you do that all fonts are distorted.

---

<div class="post-metadata">

**Author:** ![brianguenter](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/brianguenter/32/29519_2.png) [@brianguenter](https://discourse.julialang.org/u/brianguenter)\
**Post date:** [May 11, 2022, 6:21pm UTC](https://discourse.julialang.org/t/makie-aspect-ratio-3d-plot/57705/6 "2022-05-11T18:21:04Z")

</div>

I’m running into the same aspect ratio problem. Is there a better solution to the aspect ratio problem now?

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://discourse.julialang.org/u/jules)\
**Post date:** [May 11, 2022, 7:35pm UTC](https://discourse.julialang.org/t/makie-aspect-ratio-3d-plot/57705/7 "2022-05-11T19:35:03Z")

</div>

With Axis3 yes but that is more for final display of some data, not fully interactive exploration. You can only rotate around but for many things that’s enough

---

<div class="post-metadata">

**Author:** ![brianguenter](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/brianguenter/32/29519_2.png) [@brianguenter](https://discourse.julialang.org/u/brianguenter)\
**Post date:** [May 11, 2022, 9:31pm UTC](https://discourse.julialang.org/t/makie-aspect-ratio-3d-plot/57705/8 "2022-05-11T21:31:25Z")

</div>

That worked. In case anybody else runs into this problem here are the details:

```julia
ax = Axis3(fig[1,1:2],viewmode = :fit)
scale!(ax.scene,1.0,1.0,2.5)

```

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://discourse.julialang.org/u/jules)\
**Post date:** [May 12, 2022, 5:34am UTC](https://discourse.julialang.org/t/makie-aspect-ratio-3d-plot/57705/9 "2022-05-12T05:34:01Z")

</div>

[https://makie.juliaplots.org/stable/examples/blocks/axis3/#aspect](https://makie.juliaplots.org/stable/examples/blocks/axis3/#aspect)
