Skip to content

aspect_ratio=:equal in 3d plots doesn't always work? #1949

Open
@JMmontilla

Description

@JMmontilla

I have been trying to plot spheres but there are cases when the aspect_ratio=:equal command just doesn't work, example:

using Plots
function plotCC(pos, rad, n = 16) # Function to spheres
    u = collect(range(0,stop=2,length=n));
    v = collect(range(0,stop=1,length=n));
    x = pos * ones(n) * ones(n)' + rad * cospi.(u) * sinpi.(v)';
    y = rad * sinpi.(u) * sinpi.(v)';
    z = rad * repeat(cospi.(v)',outer=[n, 1])
    surface!(x,y,z, aspect_ratio=:equal)
end
plotlyjs(dpi=1500)
x = -15:0.1:10
y = -2:0.1:2
plot(x,y,(x,y) -> sin(x)*cos(y)*0.5, linetype=:surface, aspect_ratio=:equal, color=:magma)
plotCC(1,2,32)
plotCC(-15,3,32)
gui()

which will give me this:
no_AspectRatio

but if I plot the second sphere with rad=5 then this is the result:
AspectRatio

Is this some kind of limitation of Plots.jl ? It looks like it is deciding not to do aspect_ratio=:equal just because the data is too stretched, but I need to plot it with equally scaled axis (or the spheres won't look like it). Any advise?

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementimproving existing functionality

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions