# Changing the z-scale in plots3d

**URL:** <https://discourse.julialang.org/t/changing-the-z-scale-in-plots3d/54765>\
**Category:** New to Julia\
**Tags:** visualization\
**Created:** [February 6, 2021, 11:16pm UTC](https://discourse.julialang.org/t/changing-the-z-scale-in-plots3d/54765 "2021-02-06T23:16:22Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![angeloaliano1](https://avatars.discourse-cdn.com/v4/letter/a/7ea924/32.png) [@angeloaliano1](https://discourse.julialang.org/u/angeloaliano1)\
**Post date:** [February 6, 2021, 11:16pm UTC](https://discourse.julialang.org/t/changing-the-z-scale-in-plots3d/54765/1 "2021-02-06T23:16:22Z")

</div>

Dear all,  
I would like to increase the z-scale of z-axis of my figure:

```julia
plot(size=(600,500))
X(r,theta) = r * cos(theta) 
Y(r,theta) = r * sin(theta)
Z(r,theta) = -r * r
my_cg = cgrad([:blue,:red,:yellow]);

thetas = range(0, stop=2*pi, length=50)
rs = range(0, stop=1, length=50)

xs = [X(r, theta) for theta in thetas, r in rs] 
ys = [Y(r, theta) for theta in thetas, r in rs]
zs = [Z(r, theta) for theta in thetas, r in rs]

surface!(xs, ys, zs,ratio=1,
label=false,xlims=(-1.5, 1.5),
xlabel=x, ylims=(-1.5,1.5), zlims=(-1.0,1),c=my_cg)

```

That results:  
 ![paraboloide](https://global.discourse-cdn.com/julialang/original/3X/0/9/09a241b858a564c43153401d2acf2c084eef2b4c.png)  
I would like my paraboloid to be more stretched in the z direction. How can I do this?  
Many thanks.

---

<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, 12:05am UTC](https://discourse.julialang.org/t/changing-the-z-scale-in-plots3d/54765/2 "2021-02-07T00:05:10Z")

</div>

Your code does not run as is. Always indicate which packages are used.  
Try replacing `ratio = 1` by keyword `aspect_ratio = 2`

---

<div class="post-metadata">

**Author:** ![angeloaliano1](https://avatars.discourse-cdn.com/v4/letter/a/7ea924/32.png) [@angeloaliano1](https://discourse.julialang.org/u/angeloaliano1)\
**Post date:** [February 7, 2021, 12:15am UTC](https://discourse.julialang.org/t/changing-the-z-scale-in-plots3d/54765/3 "2021-02-07T00:15:33Z")

</div>

using Plots  
plotly()  
plot(size=(600,600))  
X(r,theta) = r \* cos(theta)  
Y(r,theta) = r \* sin(theta)  
Z(r,theta) = -r \* r  
my\_cg = cgrad([:blue,:red,:yellow]);

thetas = range(0, stop=2\*pi, length=50)  
rs = range(0, stop=1, length=50)

xs = [X(r, theta) for theta in thetas, r in rs]  
ys = [Y(r, theta) for theta in thetas, r in rs]  
zs = [Z(r, theta) for theta in thetas, r in rs]

surface!(xs, ys, zs,aspect\_ratio = 1.5,  
label=false,xlims=(-1.5, 1.5),  
xlabel=“x”, ylims=(-1.5,1.5), zlims=(-1.0,1),c=my\_cg)

Try now please. The same result.

---

<div class="post-metadata">

**Author:** ![ash](https://avatars.discourse-cdn.com/v4/letter/a/f19dbf/32.png) [@ash](https://discourse.julialang.org/u/ash)\
**Post date:** [February 7, 2021, 12:19am UTC](https://discourse.julialang.org/t/changing-the-z-scale-in-plots3d/54765/4 "2021-02-07T00:19:50Z")

</div>

Please format your code properly and make sure you read: [Please read: make it easier to help you](https://discourse.julialang.org/t/psa-make-it-easier-to-help-you/14757)

Why not just restrict your z-axis to a different range?

```julia
using Plots; pyplot()

plot(size=(600,500))
X(r,theta) = r * cos(theta) 
Y(r,theta) = r * sin(theta)
Z(r,theta) = -r * r
my_cg = cgrad([:blue,:red,:yellow]);

thetas = range(0, stop=2*pi, length=50)
rs = range(0, stop=1, length=50)

xs = [X(r, theta) for theta in thetas, r in rs] 
ys = [Y(r, theta) for theta in thetas, r in rs]
zs = [Z(r, theta) for theta in thetas, r in rs]

surface!(xs, ys, zs,
label=false,xlims=(-1.5, 1.5), aspect_ratio=:auto,
xlabel="x", ylims=(-1.5,1.5), zlims=(-1.0, 0),c=my_cg)

```

 ![CleanShot 2021-02-06 at 16.20.05@2x](https://global.discourse-cdn.com/julialang/original/3X/f/6/f67eb062fef042db5f283cd4972ba7289058aa80.jpeg)

---

<div class="post-metadata">

**Author:** ![angeloaliano1](https://avatars.discourse-cdn.com/v4/letter/a/7ea924/32.png) [@angeloaliano1](https://discourse.julialang.org/u/angeloaliano1)\
**Post date:** [February 7, 2021, 1:09am UTC](https://discourse.julialang.org/t/changing-the-z-scale-in-plots3d/54765/5 "2021-02-07T01:09:09Z")

</div>

The only difference is the keyword `:auto`? If I want that z-scale is three times the x-scale? How can I do this?

---

<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, 1:42am UTC](https://discourse.julialang.org/t/changing-the-z-scale-in-plots3d/54765/6 "2021-02-07T01:42:31Z")

</div>

Do not know for Julia plotly but the axes scaling works with Makie.

```julia
using Makie
x = y = LinRange(-2, 2, 100)
f(x,y) = -(x^2 + y^2)
scene = Scene(resolution = (1000, 1000))
surface!(scene, x, y, f)
scale!(scene, 1, 1, 4) 

```

4:1 scaling:

 ![makie_surface_4to1](https://global.discourse-cdn.com/julialang/original/3X/6/2/6245c725ee43933adcefe648844458aee92d7655.png)  
1:1 scaling:  
 ![makie_surface_1to1](https://global.discourse-cdn.com/julialang/original/3X/b/a/bae399e565f2360d90359343c2a7b6ba0f721dbe.jpeg)
