Adding polar plot to axes is not supported

128 vues (au cours des 30 derniers jours)
HYZ
HYZ le 8 Sep 2022
Commenté : HYZ le 8 Sep 2022
Hi,
The code works most of the time. sometimes, it showed error "Adding polar plot to axes is not supported" and I closed the matlab and ran again. Then it works for the same data.
Is there because there is a bug in Matlab when installation or the code is optimized. Please suggest. Thanks.
for i = 1: size (OSI,1)
if OSI (i) > 0.5
theta = 0 : pi/4: 2*pi;
p (i) = figure (i);
polarplot (theta, rho (i,:));
pax = gca;
thetaticks(0:45:315)
pax.ThetaDir = 'clockwise';
pax.ThetaZeroLocation = 'right';
pax.RTickLabel = []; %remove rho values inside polar plot
hlines = findall(gcf,'Type','line'); set(hlines,'LineWidth',3); %inside lines thicker
rl = rlim; hold on
polarplot([0 pi], rl(2)*[1 1], 'k--'); %connecting 0 and 180
polarplot([3*pi/2 pi/2], rl(2)*[1 1], 'k--'); %connecting 90 and 270
polarplot(linspace(0, 2*pi, 61), rl(2)*ones(61,1), 'k-', 'LineWidth', 2) %making border thicker
grid off;
title (sprintf('ROI %d: OSI %0.2f DSI %0.2f', i, OSI(i), DSI (i)))
cd(path_stim_all{itr})
saveas (gcf,strcat('ROI', '_', num2str(i), '_', 'OSI', '_', num2str (OSI(i)), 'DSI', '_', num2str (DSI(i)), '.jpeg'));
close all
end
end

Réponse acceptée

Walter Roberson
Walter Roberson le 8 Sep 2022
That error could potentially happen if figure(i) already exists and has a non-polar axis that already has "hold on" -- oh yes, and it would have to be i such that it is the first OSI(i) > 0.5 because you have the "close all" at the bottom.
You should probably not be creating a new figure each time; you should create a single figure before the loop and you should cla() each iteration, and get rid of the close all.
  1 commentaire
HYZ
HYZ le 8 Sep 2022
thanks. it works now!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

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

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by