How do I turn off the grid in a polar plot?

19 ビュー (過去 30 日間)
Ned Gulley
Ned Gulley 2011 年 1 月 13 日
コメント済み: Walter Roberson 2017 年 1 月 3 日
For a normal MATLAB plot, I can turn the grid off and on with the grid command.
x = 1:10;
plot(x,sin(x))
grid on % now the grid is on
pause(1)
grid off % now it's off
But that doesn't work for a polar plot. Plus the grid is on by default. How do I turn it off?

採用された回答

Ned Gulley
Ned Gulley 2011 年 1 月 13 日
It's a shame that it's not easier to do this, but here is a Solution that explains how to do it:
Here's the code provided in that Solution.
% create the polar plot, and store the line's handle
p = polar((0:99)*pi/100, (0:99)/100);
% find all of the lines in the polar plot
h = findall(gcf,'type','line');
% remove the handle for the polar plot line from the array
h(h == p) = [];
% delete all other lines
delete(h);
% If you want, use the following lines to remove the text.
% (I prefer to leave it in place)
% find and remove all of the text objects in the polar plot
% delete(findall(gcf,'type','text'))

その他の回答 (2 件)

Walter Roberson
Walter Roberson 2011 年 1 月 20 日
% create the polar plot, and store the line's handle
p = polar((0:99)*pi/100, (0:99)/100);
%remove lines and text objects except the main line
delete(findall(ancestor(p,'figure'),'HandleVisibility','off','type','line','-or','type','text'));
  1 件のコメント
Walter Roberson
Walter Roberson 2011 年 1 月 20 日
Answer updated to avoid relying on gcf in case the plot is in a different figure.

サインインしてコメントする。


Daniel Zuth
Daniel Zuth 2017 年 1 月 3 日
Use polarplot() instead polar() and grid off.
  1 件のコメント
Walter Roberson
Walter Roberson 2017 年 1 月 3 日
Yes, that is a good method for R2016a or later. polarplot() did not exist when the question was first posted in 2011.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangePolar Plots についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by