Changing the z-scale in plots3d

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

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
I would like my paraboloid to be more stretched in the z direction. How can I do this?
Many thanks.

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

1 Like

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.

Please format your code properly and make sure you read: PSA: make it easier to help you

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

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)

1 Like

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

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

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:


1:1 scaling:

3 Likes