Colour background for polar axes
5 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 ?
0 Kommentare
Antworten (2)
Divyajyoti Nayak
am 19 Jun. 2025
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.
0 Kommentare
Adam Danz
am 19 Jun. 2025
Bearbeitet: Adam Danz
am 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)
0 Kommentare
Siehe auch
Kategorien
Mehr zu Polar Plots finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


