Colour background for polar axes
조회 수: 8 (최근 30일)
이전 댓글 표시
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
답변 (2개)
Divyajyoti Nayak
2025년 6월 19일
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
Adam Danz
2025년 6월 19일
편집: Adam Danz
2025년 6월 19일
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
참고 항목
카테고리
Help Center 및 File Exchange에서 Polar Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


