Colour background for polar axes
9 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuestas (2)
Divyajyoti Nayak
el 19 de Jun. de 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 comentarios
Adam Danz
el 19 de Jun. de 2025
Editada: Adam Danz
el 19 de Jun. de 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 comentarios
Ver también
Categorías
Más información sobre Polar Plots en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


