Colour background for polar axes
9 ビュー (過去 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!