Andrew Davidson
Andrew Davidson

Reputation: 69

Sage: 3D plots - Aspect Ratio

I'm trying to plot the modular surface of f(z) = (z-1)(z+1).

var('x','y')
assume(x,'real')
assume(y,'real')
z = x + I*y
f = (z+1)*(z-1)
w = sqrt(expand(f*f.conjugate()))
W = plot3d(w,(x,-2,2),(y,-2,2), color='purple', opacity=0.8)
show(W, figsize=8)

The problem with the above code is that the x and y axes range from -2 to 2 while the z-axis ranges from 0 to 8. Nevertheless the z-axis has the same height in the diagram as the x and y-axis. How do I "stretch" the Z-axis so that it is 4 times as tall as the x and y-axes are wide?

Thanks.

Sage Output

Upvotes: 1

Views: 621

Answers (1)

Stop harming Monica
Stop harming Monica

Reputation: 12620

Use the keyword argument aspect_ratio:

var('x','y')
assume(x,'real')
assume(y,'real')
z = x + I*y
f = (z+1)*(z-1)
w = sqrt(expand(f*f.conjugate()))
W = plot3d(w,(x,-2,2),(y,-2,2), color='purple', opacity=0.8, aspect_ratio=[1,1,1])
show(W, figsize=8)

enter image description here

Upvotes: 1

Related Questions