我正在尝试绘制阿基米德的螺旋形:
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'.
如何删除此图像上的网格和标签?
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 = [];
生成
问题是,首先执行grid off
会以某种方式更改当前轴,然后将其设置回笛卡尔坐标系。取而代之的是,抓住直线上的手柄,然后抓住其Parent
,即极轴对象。这具有您定义的所有属性。
PS,MATLAB警告我使用polarplot
而不是polarplot
,所以我这样做了。