How to plot heatmap and contour plots in polar coordinates with Plots.jl?

It is really nice to have polar coordinates implemented in Plots.jl:

using Plots; gr()

plot(linspace(0,3π,100), rand(100), proj=:polar, m=:red)

polar

and even nicer to interact with them using the PlotlyJS backend. However, I can’t find documentation on how to plot heatmaps and contour plots in polar coordinates. Could you please give a hand?

1 Like

This works with pyplot() but almost no other backend:

pyplot()
r = linspace(0,10,11)
θ = linspace(0,360,361)
f(r,θ) = r^2
hm = heatmap(f.(r,θ'), aspect_ratio=:equal, proj=:polar, legend=false)

image

7 Likes

Thank you @mohamed82008 that is very helpful already. Also, nice trick with dot syntax and transposing theta.

Not mine :slight_smile: got it from Steven https://github.com/stevengj/18S096-iap17/blob/master/lecture6/Numerical-Analysis.ipynb. There are also nice contour plots near the end of that notebook with PyPlot.jl.

2 Likes

indeed, very nice trick. thanks, m and s.

the url is dead.

It was moved to another directory https://github.com/stevengj/18S096/blob/master/lectures/other/Numerical-Analysis.ipynb.