Colour background for polar axes

9 views (last 30 days)
Rob L
Rob L on 10 Apr 2019
Edited: Adam Danz on 19 Jun 2025
I am trying to recreate a display (which has a black background) with a polar plot.
If I use polarplot I cannot add patch items to the display. If I use polar as an alternative I seem unable o display the axis with black (background) colour. Is it possible to do this ?

Answers (2)

Divyajyoti Nayak
Divyajyoti Nayak on 19 Jun 2025
Hi @Rob L,
The background color of a polar axes can be changed by setting the 'Color' property of the 'polaraxes' object. Here's some sample code to demonstrate:
p = polaraxes;
p.Color = 'black';
p.GridColor = 'white';
Here's a link to the documentation for properties of the 'polaraxes' object.

Adam Danz
Adam Danz on 19 Jun 2025
Edited: Adam Danz on 19 Jun 2025
In MATLAB R2025a (and later), patch and surface objects are supported in polaraxes; so is dark theme.
R2025a
pax = polaraxes();
patch(pax, [0 60 150 240 360]*pi/180, [2 1 2 1 2],'c','FaceAlpha',0.6)
theme dark
% Don't use this next line - it's a workaround to display the figure
% properly in MATLAB Answers.
set(gcf,'Color',pax.Color)
Prior to R2025a, using the not-recommended polar() function
figure()
pline = polar([0 60 150 240 360]*pi/180, [2 1 2 1 2]);
paxOld = ancestor(pline,'axes');
paxBackgroundPatch = findall(paxOld,'Type','patch');
paxBackgroundPatch.FaceColor = [.2 .2 .2];
[x,y] = pol2cart([0 60 150 240 360]*pi/180, [2 1 2 1 2]);
patch(x,y,'c','FaceAlpha', 0.6,'EdgeColor','w','EdgeAlpha',0.6)

Categories

Find more on Polar Plots in Help Center and File Exchange

Products


Release

R2016b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!