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

**URL:** <https://discourse.julialang.org/t/how-to-plot-heatmap-and-contour-plots-in-polar-coordinates-with-plots-jl/7817>\
**Category:** Visualization\
**Tags:** question, plotting\
**Created:** [December 17, 2017, 5:00pm UTC](https://discourse.julialang.org/t/how-to-plot-heatmap-and-contour-plots-in-polar-coordinates-with-plots-jl/7817 "2017-12-17T17:00:02Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![juliohm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juliohm/32/215266_2.png) [@juliohm](https://discourse.julialang.org/u/juliohm)\
**Post date:** [December 17, 2017, 5:00pm UTC](https://discourse.julialang.org/t/how-to-plot-heatmap-and-contour-plots-in-polar-coordinates-with-plots-jl/7817/1 "2017-12-17T17:00:02Z")

</div>

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

```julia
using Plots; gr()

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

```

![polar](https://global.discourse-cdn.com/julialang/original/3X/e/f/ef5db94fa95dcb61c1ed427a039e36d8f856cb9f.png)

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?

---

<div class="post-metadata">

**Author:** ![mohamed82008](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mohamed82008/32/18171_2.png) [@mohamed82008](https://discourse.julialang.org/u/mohamed82008)\
**Post date:** [December 17, 2017, 6:13pm UTC](https://discourse.julialang.org/t/how-to-plot-heatmap-and-contour-plots-in-polar-coordinates-with-plots-jl/7817/2 "2017-12-17T18:13:55Z")

</div>

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

```julia
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](https://global.discourse-cdn.com/julialang/original/3X/4/b/4bdfcfa0fc2b9053b069310dbed8ef742614fbb0.png)

---

<div class="post-metadata">

**Author:** ![juliohm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juliohm/32/215266_2.png) [@juliohm](https://discourse.julialang.org/u/juliohm)\
**Post date:** [December 17, 2017, 6:29pm UTC](https://discourse.julialang.org/t/how-to-plot-heatmap-and-contour-plots-in-polar-coordinates-with-plots-jl/7817/3 "2017-12-17T18:29:52Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![mohamed82008](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mohamed82008/32/18171_2.png) [@mohamed82008](https://discourse.julialang.org/u/mohamed82008)\
**Post date:** [December 17, 2017, 6:37pm UTC](https://discourse.julialang.org/t/how-to-plot-heatmap-and-contour-plots-in-polar-coordinates-with-plots-jl/7817/4 "2017-12-17T18:37:11Z")

</div>

> [@juliohm](#):
>
> Also, nice trick with dot syntax and transposing theta.

Not mine 🙂 got it from Steven [https://github.com/stevengj/18S096-iap17/blob/master/lecture6/Numerical-Analysis.ipynb](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.

---

<div class="post-metadata">

**Author:** ![iwelch](https://avatars.discourse-cdn.com/v4/letter/i/8c91f0/32.png) [@iwelch](https://discourse.julialang.org/u/iwelch)\
**Post date:** [March 17, 2018, 5:52am UTC](https://discourse.julialang.org/t/how-to-plot-heatmap-and-contour-plots-in-polar-coordinates-with-plots-jl/7817/5 "2018-03-17T05:52:08Z")

</div>

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

> [@mohamed82008](#):
>
> Steven [https://github.com/stevengj/18S096-iap17/blob/master/lecture6/Numerical-Analysis.ipynb](https://github.com/stevengj/18S096-iap17/blob/master/lecture6/Numerical-Analysis.ipynb)

the url is dead.

---

<div class="post-metadata">

**Author:** ![mohamed82008](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mohamed82008/32/18171_2.png) [@mohamed82008](https://discourse.julialang.org/u/mohamed82008)\
**Post date:** [March 17, 2018, 7:40am UTC](https://discourse.julialang.org/t/how-to-plot-heatmap-and-contour-plots-in-polar-coordinates-with-plots-jl/7817/6 "2018-03-17T07:40:09Z")

</div>

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