# Unable to plot a sphere surface using Plots package

**URL:** <https://discourse.julialang.org/t/unable-to-plot-a-sphere-surface-using-plots-package/60194>\
**Category:** Visualization\
**Tags:** plotting, plots\
**Created:** [April 28, 2021, 6:49pm UTC](https://discourse.julialang.org/t/unable-to-plot-a-sphere-surface-using-plots-package/60194 "2021-04-28T18:49:18Z")\
**Posts on this page:** 1\
**Showing post:** 8

<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 29, 2021, 8:54pm UTC](https://discourse.julialang.org/t/unable-to-plot-a-sphere-surface-using-plots-package/60194/8 "2021-04-29T20:54:23Z")

</div>

Just for the record, a decent sphere can be produced with Plots.jl gr() back-end by splitting it in two (_top and bottom surfaces)_. However, it requires a careful computation of the end points for a nice stitching job and minding the plotting order.

```julia
using Plots; gr()

zplus(x,y) = (x^2 + y^2) <= 1 ? sqrt.(abs.(1.0 .- x.^2 .- y.^2)) : NaN
zminus(x,y) = (x^2 + y^2) <= 1 ? -sqrt.(abs.(1.0 .- x.^2 .- y.^2)) : NaN

x = collect(-1:0.01:1);
y = @. (1-x^2)^0.5
y = reshape(permutedims([-y y]),:,1)[:]
x = sort([x; x.+eps()])

surface(x,y,zminus, ratio=:equal,xlims=(-1,1),ylims=(-1,1),zlims=(-1,1)) # isometric
surface!(x,y,zplus, ratio=:equal,xlims=(-1,1),ylims=(-1,1),zlims=(-1,1)) # isometric

```

![Plots_gr_sphere_2_halves](https://global.discourse-cdn.com/julialang/original/3X/4/c/4c8515cf9b9d0cbece9acebd7f5bba36911b487a.png)

---

_[View the full topic](https://discourse.julialang.org/t/unable-to-plot-a-sphere-surface-using-plots-package/60194)._
