Adding polar plot to axes is not supported

조회 수: 134 (최근 30일)
HYZ
HYZ 2022년 9월 8일
댓글: HYZ 2022년 9월 8일
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

채택된 답변

Walter Roberson
Walter Roberson 2022년 9월 8일
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.

추가 답변 (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