# (Plots.jl) aspect\_ratio=1.0 for 3d plot

**URL:** <https://discourse.julialang.org/t/plots-jl-aspect-ratio-1-0-for-3d-plot/58607>\
**Category:** Visualization\
**Tags:** plotting, plots\
**Created:** [April 5, 2021, 10:57am UTC](https://discourse.julialang.org/t/plots-jl-aspect-ratio-1-0-for-3d-plot/58607 "2021-04-05T10:57:08Z")\
**Posts on this page:** 1\
**Showing post:** 2

<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:** [April 5, 2021, 1:35pm UTC](https://discourse.julialang.org/t/plots-jl-aspect-ratio-1-0-for-3d-plot/58607/2 "2021-04-05T13:35:48Z")

</div>

@iHany, see revised improved solution using `gr()` backend below.

```julia
using Plots; gr(size=(600,600))

function plot_iso3d(xs, ys, zs; lw=3, lc=:red, title="Isometric 3D plot",label=false, camera=(45,30))
    # condition data for nearly isometric 3D plot 
    x12, y12, z12 = extrema(xs), extrema(ys), extrema(zs)
    d = maximum([diff([x12...]),diff([y12...]),diff([z12...])])[1] / 2
    xm, ym, zm = mean(x12), mean(y12), mean(z12) 

    # plot data
    p = Plots.plot(; xlabel="x",ylabel="y",zlabel="z", aspect_ratio=:equal, grid=:true)
    Plots.plot!(xlims=(xm-d,xm+d), ylims=(ym-d,ym+d), zlims=(zm-d,zm+d))
    Plots.plot!(;camera=camera) #(azimuth,elevation) ???
    Plots.plot!(xs, ys, zs, title=title,lw=lw,lc=lc,label=label)
    Plots.plot!(xs, ys, zlims(p)[1] .+ 0*zs, lw=1, lc=:lightgray, label=false)
    Plots.plot!(xs, ylims(p)[2] .+ 0*ys, zs, lw=1, lc=:lightgray, label=false)
    Plots.plot!(xlims(p)[1] .+ 0*xs, ys, zs, lw=1, lc=:lightgray, label=false)
end

#input data
N = 100
xs = LinRange(0,40,N)
ys = LinRange(0,20,N) .+ 10*sin.(xs)
zs = LinRange(-10,50,N) .+ 15*sin.(xs)
plot_iso3d(xs, ys, zs)

```

 ![Isometric_3d_plot_with_shadow](https://global.discourse-cdn.com/julialang/original/3X/5/b/5b90973c45b2767608ee398bc44e2d61f0c8dce1.png)

---

_[View the full topic](https://discourse.julialang.org/t/plots-jl-aspect-ratio-1-0-for-3d-plot/58607)._
