# How to plot heatmap function over the unit circle

I have a function $Z(r, \theta)$ that I would like to plot over the unit disk. I could of course plot it as $Z(\sqrt{x^2+y^2}, \arctan(y/x))$, but the best I can do with this is a square plot. I would like a plot defined from $0<R<1$ and $0<\theta<2\pi$, such that it looks something like the plots shown here:

How can I make Mathematica generate a plot like this? Thank you!

• You might be interested in RegionFunction. – J. M. is in limbo Nov 24 '15 at 6:07
• Ah that works perfectly - thank you!! Though I do wonder if Mathematica has something more intuitive built in, as it seems like a common enough application. – Bslugger360 Nov 24 '15 at 6:10
• Just to be clear, I'm still leaving this open for a solution as this method doesn't quite work - using $\arctan(y/x)$ causes discontinuities at x=0 that mess up the way the plot comes out. – Bslugger360 Nov 24 '15 at 6:34
• That's because you have to use two-argument arctangent (ArcTan[x, y]) for the purpose. – J. M. is in limbo Nov 24 '15 at 6:39

Here's my attempt to plot the Zernike functions on the unit disk:

ZernikeZ[n_Integer, m_Integer, r_, θ_] /; -n <= m <= n :=
If[m < 0, Sin[m θ], Cos[m θ]] ZernikeR[n, m, r]

Table[DensityPlot[ZernikeZ[n, m, Norm[{x, y}], ArcTan[x, y]], {x, y} ∈ Disk[],
ColorFunction -> (ColorData[{"ThermometerColors",  "Reverse"},
LogisticSigmoid[2 #]] &),
ColorFunctionScaling -> False, Frame -> False,
PlotPoints -> 55],
{n, 0, 4}, {m, -n, n, 2}] // GraphicsGrid

• (Older versions of Mathematica can use RegionFunction instead.) – J. M. is in limbo Nov 24 '15 at 6:44
• Much older ones ... v9 accepts Disk[ ] – Dr. belisarius Nov 24 '15 at 6:46
• Is the LogisticSigmoid[ ] in there for pure Fermi love, or is something really useful? – Dr. belisarius Nov 24 '15 at 6:47
• @bel, it allows me to map $(-\infty,\infty)$ to $(0,1)$, with $0$ being the white(-ish) color, and positive and negative values mapped to the extreme colors. I've used this rescaling before on this site... – J. M. is in limbo Nov 24 '15 at 6:49
• Ah, OK.nice one.Don't remember seeing it used like this before, but the German doctor is always mumbling in my ear trying to distract me, so ... – Dr. belisarius Nov 24 '15 at 6:51