# 3D Polar surface plot in Julia

**URL:** <https://discourse.julialang.org/t/3d-polar-surface-plot-in-julia/94537>\
**Category:** New to Julia\
**Tags:** plots, makie, plotlyjs\
**Created:** [February 13, 2023, 5:54am UTC](https://discourse.julialang.org/t/3d-polar-surface-plot-in-julia/94537 "2023-02-13T05:54:46Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![yewalenikhil65](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yewalenikhil65/32/26873_2.png) [@yewalenikhil65](https://discourse.julialang.org/u/yewalenikhil65)\
**Post date:** [February 13, 2023, 5:54am UTC](https://discourse.julialang.org/t/3d-polar-surface-plot-in-julia/94537/1 "2023-02-13T05:54:46Z")

</div>

I feel there is a need of 3D Polar surface plots. Does any one have Julia equivalent of following MATLAB function ? [3D Polar Plot - File Exchange - MATLAB Central](https://in.mathworks.com/matlabcentral/fileexchange/13200-3d-polar-plot)

---

<div class="post-metadata">

**Author:** ![empet](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/empet/32/221303_2.png) [@empet](https://discourse.julialang.org/u/empet)\
**Post date:** [February 13, 2023, 12:32pm UTC](https://discourse.julialang.org/t/3d-polar-surface-plot-in-julia/94537/2 "2023-02-13T12:32:19Z")

</div>

To plot a surface in polar coordinates does not require a special setup. It is just a parameterized surface, of parameters r and θ.  
If you have the surface equation given as z=f(r,θ), r\in [0, r\_{max}], \theta\in [\alpha, \beta], then you get the surface parameterization:

```julia
r = range(0, rmax, 30)
θ = range(α, β, 100)
z= [f(s, t) for t in θ, s in r]
x = cos.(θ) * r' #outer product;
y = sin.(θ) * r'

```

Now you can plot the surface plot as a `surface(x,y,z)`. At the same time you can project this surface onto an horizontal plane, z=h, and its projection is a disk or a part of disk,of radius r\_{max}. With PlotlyJS you can add the angles around the disk, as 3d annotations.  
Could you post your equation `z=f(r,θ)`?

---

<div class="post-metadata">

**Author:** ![yewalenikhil65](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yewalenikhil65/32/26873_2.png) [@yewalenikhil65](https://discourse.julialang.org/u/yewalenikhil65)\
**Post date:** [February 13, 2023, 2:43pm UTC](https://discourse.julialang.org/t/3d-polar-surface-plot-in-julia/94537/3 "2023-02-13T14:43:08Z")

</div>

Hi @empet , I used same technique of using parameterized definition myself. The surface generated looks good… but I was hoping like in `polarplots` it shows the `\theta` in degrees along the circle… The figures are well-annotated in circular manner. I wished to know if something like that exists.

The equation that I was plotting was that of Bessels function for vibration of circular membranes

---

<div class="post-metadata">

**Author:** ![empet](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/empet/32/221303_2.png) [@empet](https://discourse.julialang.org/u/empet)\
**Post date:** [February 13, 2023, 3:34pm UTC](https://discourse.julialang.org/t/3d-polar-surface-plot-in-julia/94537/4 "2023-02-13T15:34:04Z")

</div>

I represented an arbitrary function depending on polar coordinates, and added its projection (but it’s not mandatory) and the angle θ in degree:  
[https://nbviewer.org/gist/empet/904b27982793bdef09c348a3699373d6](https://nbviewer.org/gist/empet/904b27982793bdef09c348a3699373d6)

---

<div class="post-metadata">

**Author:** ![empet](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/empet/32/221303_2.png) [@empet](https://discourse.julialang.org/u/empet)\
**Post date:** [February 13, 2023, 4:22pm UTC](https://discourse.julialang.org/t/3d-polar-surface-plot-in-julia/94537/5 "2023-02-13T16:22:21Z")

</div>

I implemented Circular membrane vibration in Python, a few years ago, and imported  
the Bessel functions of the first kind, and their zeros from `scipy.special`.  
Could you please point out a Julia package for Bessel functions?  
LE: I found both functions, respectively in SpecialFunctions.jl, and FunctionZeros.jl

---

<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:** [February 13, 2023, 7:52pm UTC](https://discourse.julialang.org/t/3d-polar-surface-plot-in-julia/94537/6 "2023-02-13T19:52:58Z")

</div>

Such PlotlyJS 3D text annotation is [currently not possible with Plots.jl](https://github.com/JuliaPlots/Plots.jl/issues/362).  
Is it possible with Makie?

---

<div class="post-metadata">

**Author:** ![empet](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/empet/32/221303_2.png) [@empet](https://discourse.julialang.org/u/empet)\
**Post date:** [February 13, 2023, 8:37pm UTC](https://discourse.julialang.org/t/3d-polar-surface-plot-in-julia/94537/7 "2023-02-13T20:37:19Z")

</div>

I don’t know if Makie provides 3d annotations.

---

<div class="post-metadata">

**Author:** ![empet](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/empet/32/221303_2.png) [@empet](https://discourse.julialang.org/u/empet)\
**Post date:** [February 13, 2023, 8:39pm UTC](https://discourse.julialang.org/t/3d-polar-surface-plot-in-julia/94537/8 "2023-02-13T20:39:30Z")

</div>

Animation of a circular membrane vibration, represented as polar surface, with annotated angles:  
[Vibrational mode (2, 1) with 1 diametric and 2 circular node lines] ([https://media.giphy.com/media/Qz11Z49hmsUcktU3kS/giphy.gif](https://media.giphy.com/media/Qz11Z49hmsUcktU3kS/giphy.gif))

---

<div class="post-metadata">

**Author:** ![yewalenikhil65](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yewalenikhil65/32/26873_2.png) [@yewalenikhil65](https://discourse.julialang.org/u/yewalenikhil65)\
**Post date:** [February 14, 2023, 11:58am UTC](https://discourse.julialang.org/t/3d-polar-surface-plot-in-julia/94537/9 "2023-02-14T11:58:52Z")

</div>

Yes… I had used SpecialFunctions.jl(for bessel function definition) and FastGaussQuadrature.jl (for the roots of Bessel functions)

---

<div class="post-metadata">

**Author:** ![yewalenikhil65](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yewalenikhil65/32/26873_2.png) [@yewalenikhil65](https://discourse.julialang.org/u/yewalenikhil65)\
**Post date:** [February 14, 2023, 12:00pm UTC](https://discourse.julialang.org/t/3d-polar-surface-plot-in-julia/94537/10 "2023-02-14T12:00:13Z")

</div>

Thanks @empet for the annotaton of angles in degrees. Its the only part I was missing in aesthetics. Rest I managed with FastGaussQuadrature.jl and SpecialFunctions.jl
