How do I remove the border of a polarplot?

26 views (last 30 days)
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 Comment
Benxyzzy
Benxyzzy on 1 Aug 2018
Edited: Benxyzzy on 1 Aug 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!

Sign in to comment.

Accepted Answer

Star Strider
Star Strider on 20 May 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.

More Answers (2)

Morteza Amini
Morteza Amini on 13 Oct 2020
Simply use the following:
set(gca,'visible','off');
  1 Comment
Adam Danz
Adam Danz on 14 Oct 2020
Edited: Adam Danz on 18 Feb 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

Sign in to comment.


Christian Hofmann
Christian Hofmann on 18 Feb 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 Comment
Adam Danz
Adam Danz on 18 Feb 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)

Sign in to comment.

Categories

Find more on Polar Plots in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!