# Makie: adjusting axis scale / limits in 3D

**URL:** https://discourse.julialang.org/t/makie-adjusting-axis-scale-limits-in-3d/29231
**Category:** Visualization
**Tags:** plotting, makie
**Created:** [September 27, 2019, 12:45pm UTC](https://discourse.julialang.org/t/makie-adjusting-axis-scale-limits-in-3d/29231 "2019-09-27T12:45:39Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![mihai](https://avatars.discourse-cdn.com/v4/letter/m/35a633/32.png) [@mihai](https://discourse.julialang.org/u/mihai)
#### Post date: [September 27, 2019, 12:45pm UTC](https://discourse.julialang.org/t/makie-adjusting-axis-scale-limits-in-3d/29231/1 "2019-09-27T12:45:39Z")

</div>

Hello,

I would like to use very non-isotropic axis scales in 3D scatter plots. I can set the limits of the axis, but couldn’t find a working way of changing the data scaling in x/y/z (so that the plot is not overly stretched in one dimension). Is there any easy way (without scaling the data itself)? I tried modifying the “scale” attribute of the Axis3D, to no avail.

minimal example:

```julia
using Makie

R = 4.0
x = randn(100_000)
y = randn(100_000)
z = randn(100_000) * R

lim = FRect3D((-4,-4,-4*R),(8,8,8*R))
scatter(x, y, z, markersize = 0.001, transparency=true, alpha=0.1, limits=lim)

```

how do I scale in z-dimension by 1/R ?

---

<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: [September 27, 2019, 12:54pm UTC](https://discourse.julialang.org/t/makie-adjusting-axis-scale-limits-in-3d/29231/2 "2019-09-27T12:54:39Z")

</div>

using Makie

R = 4.0  
x = randn(100\_000)  
y = randn(100\_000)  
z = randn(100\_000) \* R

lim = FRect3D((-4,-4,-4_R),(8,8,8_R))  
scene = scatter(x, y, z, markersize = 0.001, transparency=true, alpha=0.1, limits=lim)  
scale!(scene, 1, 1, 1/R)

```julia
Or 

```

scene = scatter(x, y, z, markersize = 0.001, transparency=true, alpha=0.1, limits=lim, scale = (1.0, 1.0, 1/R)

```julia

```

---

<div class="post-metadata">

### Author: ![mihai](https://avatars.discourse-cdn.com/v4/letter/m/35a633/32.png) [@mihai](https://discourse.julialang.org/u/mihai)
#### Post date: [September 27, 2019, 1:03pm UTC](https://discourse.julialang.org/t/makie-adjusting-axis-scale-limits-in-3d/29231/3 "2019-09-27T13:03:18Z")

</div>

Great, thanks!

Is there also a way to control the pivot point for mouse rotation?

---

<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: [September 27, 2019, 1:06pm UTC](https://discourse.julialang.org/t/makie-adjusting-axis-scale-limits-in-3d/29231/4 "2019-09-27T13:06:38Z")

</div>

Yeah, via panning with the middle mouse button…  
You can also set it via:  
[https://github.com/JuliaPlots/AbstractPlotting.jl/blob/master/src/camera/camera3d.jl#L301](https://github.com/JuliaPlots/AbstractPlotting.jl/blob/master/src/camera/camera3d.jl#L301)

```julia
update_cam!(scene, eyeposition, lookat) # lookat == pivot point

```

As you can see in the source, you can get the current eyeposition via `cameracontrols(scene).eyeposition[]`

---

<div class="post-metadata">

### Author: ![mihai](https://avatars.discourse-cdn.com/v4/letter/m/35a633/32.png) [@mihai](https://discourse.julialang.org/u/mihai)
#### Post date: [April 24, 2020, 4:36pm UTC](https://discourse.julialang.org/t/makie-adjusting-axis-scale-limits-in-3d/29231/5 "2020-04-24T16:36:35Z")

</div>

Hi and thanks again for the answer!

As I’m coming back to this, I’m having a related problem with the text font size being in data units. If I try to scale that, it fails at larger values, producing graphical glitches… maybe because textsize is an Integer? Or it could just be my GPU (Integrated Intel Iris Pro 5200), I don’t know.

example:

```julia
using Makie

function testTicks(f)
    x = [0,1,0,1,0,1,0,1]
    y = [0,0,1,1,0,0,1,1]
    z = [0,0,0,0,1,1,1,1] .* f
    s = Scene(resolution=(500,400))
    scatter!(s,x,y,z, markersize=f/50)
    Makie.scale!(s,(f,f,1))
    s[:limits] = FRect3D((0,0,0),(1,1,1*f))
    s[Axis][:ticks,:textsize] = (f*5,f*5,f*5)
    return s
end

```

while testTicks(1e6) works for me, I’m seeing random gray triangles with ~1e8 or above.  
Any advice, besides rescaling the data and manually setting the tick positions / labels?

---

<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: [February 7, 2021, 8:10pm UTC](https://discourse.julialang.org/t/makie-adjusting-axis-scale-limits-in-3d/29231/6 "2021-02-07T20:10:10Z")

</div>

Resurrecting this Makie thread as I cannot get the axes limits to work in 3D surface plots by using the keyword `limits` as indicated above. Running Julia Version 1.6.0-beta1.0 on Win10 VS Code.  
_PS: the following workaround sets NaNs outside the z-limits but the plot edges are not properly shaved… Is there any option to smooth the edges?_

```julia
using Makie
x = y = LinRange(-2, 2, 200)
f(x,y) = -(x^2 + y^2)
scene = Scene(resolution = (1000, 1000))
zlimf(x,y) = -2 < (z = f(x,y)) < -0.5 ? z : NaN # z-limiting function (workaround)
surface!(scene, x, y, zlimf)

```

 ![makie_surface_zlimits](https://global.discourse-cdn.com/julialang/original/3X/1/5/15f020402c2e11706552b4bc501fb0b5544e37b9.jpeg)
