How do I remove the border of a polarplot?

9 vues (au cours des 30 derniers jours)
Frouwko Wisman
Frouwko Wisman le 20 Mai 2017
Commenté : Adam Danz le 18 Fév 2021
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 commentaire
Benxyzzy
Benxyzzy le 1 Août 2018
Modifié(e) : Benxyzzy le 1 Août 2018
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!

Connectez-vous pour commenter.

Réponse acceptée

Star Strider
Star Strider le 20 Mai 2017
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.

Plus de réponses (2)

Morteza Amini
Morteza Amini le 13 Oct 2020
Simply use the following:
set(gca,'visible','off');
  1 commentaire
Adam Danz
Adam Danz le 14 Oct 2020
Modifié(e) : Adam Danz le 18 Fév 2021
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

Connectez-vous pour commenter.


Christian Hofmann
Christian Hofmann le 18 Fév 2021
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 commentaire
Adam Danz
Adam Danz le 18 Fév 2021
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)

Connectez-vous pour commenter.

Catégories

En savoir plus sur Polar Plots dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by