# 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.'s discontentment 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.'s discontentment 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.'s discontentment 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.'s discontentment 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
{"ft_lang_label":"__label__en","ft_lang_prob":0.9004693,"math_prob":0.88943875,"size":537,"snap":"2020-45-2020-50","text_gpt3_token_len":174,"char_repetition_ratio":0.10318949,"word_repetition_ratio":0.10869565,"special_character_ratio":0.32960895,"punctuation_ratio":0.140625,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9937947,"pos_list":[0,1,2,3,4],"im_url_duplicate_count":[null,4,null,4,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2020-10-31T17:07:18Z\",\"WARC-Record-ID\":\"<urn:uuid:2ae83a4d-c393-4b1a-b6fc-da1520dc9ac3>\",\"Content-Length\":\"156650\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:07d072bc-23dc-444d-89de-9c3cd07d60c8>\",\"WARC-Concurrent-To\":\"<urn:uuid:86a647b7-f994-4709-ad6a-f4c78b8f04b6>\",\"WARC-IP-Address\":\"151.101.193.69\",\"WARC-Target-URI\":\"https://mathematica.stackexchange.com/questions/100299/how-to-plot-heatmap-function-over-the-unit-circle\",\"WARC-Payload-Digest\":\"sha1:63A7REZ6WLDFJ23CIP3SYYRW4GGVF4ZK\",\"WARC-Block-Digest\":\"sha1:YEJYNEXVEG5MBR3V3KZ5GO3WDXFH3Z42\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2020/CC-MAIN-2020-45/CC-MAIN-2020-45_segments_1603107919459.92_warc_CC-MAIN-20201031151830-20201031181830-00032.warc.gz\"}"}