How do I remove the border of a polarplot?

9 次查看(过去 30 天)
Hi, I have an exercise in which i need to evaluate some graphic handles of MATLAB (I use R2014b)
I have created the following plot.
How do I remove the thin circular boundary from this plot?
That is the thin grey boundary, So it is not about the rectangular box.
I've used the following code to create my graph
clc; close all
figure(1);
theta = linspace(0,2*pi,201);
r = sqrt(abs(2*sin(5*theta)));
h = polar(theta,r);
patch( get(h,'XData'), get(h,'YData'), 'k')
delete(findall(gcf,'type','line','-or','type','text'));
box on
ax = gca;
ax.Title.String = 'Flower Power';
ax.Title.FontWeight = 'normal';
ax.Visible = 'on';
ax.XGrid = 'off';
ax.XTick = [];
ax.YTick = [];
ax.XTickLabel = [];
ax.YTickLabel = [];
ax.LineWidth = 2;
  1 个评论
Benxyzzy
Benxyzzy 2018-8-1
编辑:Benxyzzy 2018-8-1
I too have this problem, and I need to use polarplot.
It seems to be pot luck which properties, when changed, also change the circular border.
ax = gca; % PolarAxis from preexisting polarplot()
ax.ThetaAxis.LineWidth = 20
% Just changes the border, but can't be set to 0
ax.ThetaAxis.Visible = 'off'
% Removes both the border AND the angle labels.
% other ThetaAxis props eg. Color also change labels
ax.LineWidth = 20
% Changes both the border AND all gridlines,
% but not data lines, and again cannot be 0
At least with the old polar() I could findall lines and delete manually*. But now findall lines on a PolarAxis just returns handles to the data lines! What a mess.
*and note that given the old polar drew to Cartesian axes, Star Strider's answer essentially resorts to reproducing this by hand!

请先登录,再进行评论。

采纳的回答

Star Strider
Star Strider 2017-5-20
You cannot change much with the polar function. (The polarplot function was introduced in R2016a to make the plot more usable.)
Try this instead:
theta = linspace(0,2*pi,500);
r = sqrt(abs(2*sin(5*theta)));
[x,y] = pol2cart(theta, r);
figure(1)
plot(x, y)
hold on
patch([x fliplr(x)], [zeros(size(y)) fliplr(y)], 'k', 'EdgeColor','none')
hold off
axis equal
set(gca, 'XTick',[], 'YTick',[], 'XColor','none', 'YColor','none')
title('\itFlower Power!\rm', 'FontSize',20)
To produce:
The blue haze near the centre is probably due to aliasing. If you have the same problem, you may have to experiment with different renderers to get rid of it.

更多回答(2 个)

Morteza Amini
Morteza Amini 2020-10-13
Simply use the following:
set(gca,'visible','off');
  1 个评论
Adam Danz
Adam Danz 2020-10-14
编辑:Adam Danz 2021-2-18
That does not get rid of the gray circle. That only removes the black rectangular frame in the depreciated polar() function.
In the newer polarplot|polaraxes you just need,
axis off
Demo (patch is still not supported in polaraxes):
figure('color','w');
theta = linspace(0,2*pi,201);
r = sqrt(abs(2*sin(5*theta)));
h = polarplot(theta,r);
axis off

请先登录,再进行评论。


Christian Hofmann
Christian Hofmann 2021-2-18
In case someone else tries to get rid of the gray circle, setting the PolarAxes property "GridAlpha" to 0 might help:
gca.GridAlpha = 0.0
  1 个评论
Adam Danz
Adam Danz 2021-2-18
This does remove the grid and surrounding polar axis line but maintains the ticks which may be desirable for some usecases. However, gca.<property> is not supported unless gca is no longer a function but a variable name which is not recommended.
figure('color','w');
theta = linspace(0,2*pi,201);
r = sqrt(abs(2*sin(5*theta)));
h = polarplot(theta,r);
set(gca, 'GridAlpha', 0.0)

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Polar Plots 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by