# Drawing parametric surfaces in Plots.jl

**URL:** <https://discourse.julialang.org/t/drawing-parametric-surfaces-in-plots-jl/36560>\
**Category:** General Usage\
**Created:** [March 26, 2020, 5:25pm UTC](https://discourse.julialang.org/t/drawing-parametric-surfaces-in-plots-jl/36560 "2020-03-26T17:25:19Z")\
**Posts on this page:** 1\
**Showing post:** 9

<div class="post-metadata">

**Author:** ![rrhiemstra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rrhiemstra/32/12263_2.png) [@rrhiemstra](https://discourse.julialang.org/u/rrhiemstra)\
**Post date:** [October 5, 2020, 11:59am UTC](https://discourse.julialang.org/t/drawing-parametric-surfaces-in-plots-jl/36560/9 "2020-10-05T11:59:48Z")

</div>

```julia
using Plots
plotly() # or pyplot() - gr() does not work for me

# spherical: (radius r, inclination θ, azimuth φ)
X(r,theta,phi) = r * sin(theta) * sin(phi)
Y(r,theta,phi) = r * sin(theta) * cos(phi)
Z(r,theta,phi) = r * cos(theta)

thetas = range(0, stop=pi, length=50)
phis = range(0, stop=pi/2, length=50)

xs = [X(1, theta, phi) for theta in thetas, phi in phis] 
ys = [Y(1, theta, phi) for theta in thetas, phi in phis]
zs = [Z(1, theta, phi) for theta in thetas, phi in phis]

surface(xs, ys, zs)

```

![surface](https://global.discourse-cdn.com/julialang/original/3X/5/d/5dbf787f1c1abde8b2445a936634e55c1f640773.png)

---

_[View the full topic](https://discourse.julialang.org/t/drawing-parametric-surfaces-in-plots-jl/36560)._
