Adding polar plot to axes is not supported
128 次查看(过去 30 天)
显示 更早的评论
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
0 个评论
采纳的回答
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 Center 和 File Exchange 中查找有关 Polar Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!