如何删除极坐标图上的theta网格和半径网格?

问题描述 投票:1回答:1

我正在尝试绘制阿基米德的螺旋形:

t = linspace(0,5*pi,1000);
a =1;
r = a.*t;
polar(t,r);
grid off;
Ax = gca; 
Ax.ThetaGrid = 'off';
Ax.RGrid = 'off';
Ax.RTickLabel = []; 
Ax.ThetaTickLabel = [];

但是,显示以下错误:

Unrecognized property 'ThetaGrid' for class 'matlab.graphics.axis.Axes'.

如何删除此图像上的网格和标签?

matlab plot matlab-figure
1个回答
1
投票
t = linspace(0,5*pi,1000);
a =1;
r = a.*t;
line_handle = polarplot(t,r); % Get line handle
Ax = line_handle.Parent; % Get its parent, i.e. polar axes
grid off;
Ax.ThetaGrid = 'off';
Ax.RGrid = 'off';
Ax.RTickLabel = [];
Ax.ThetaTickLabel = [];

生成

enter image description here

问题是,首先执行grid off会以某种方式更改当前轴,然后将其设置回笛卡尔坐标系。取而代之的是,抓住直线上的手柄,然后抓住其Parent,即极轴对象。这具有您定义的所有属性。

PS,MATLAB警告我使用polarplot而不是polarplot,所以我这样做了。

© www.soinside.com 2019 - 2024. All rights reserved.