Problems doing subplot command while using mmpolar function

조회 수: 12 (최근 30일)
Hi,
I have a problem. I want to do a serie of subplots using mmpolar function. It seems that what I get is only one mmpolar plot in the center, even though I see the subplot divisions.
This is what I get :
What I want is 3 mmpolar plots in each of the axes shown in the background. Thank you for your help.
Here is the part of my code where I initialize my plots and stuff :
[Xeve,Yeve]=meshgrid((yDeb:res:yFin),(xDeb:res:xFin));
%On converti les axes en polaire [r,th]=meshgrid(linspace(0,100,200),linspace(0,2*pi,360)); xp=r.*cos(th); yp=r.*sin(th); zp1=interp2(Xeve,Yeve,PerrE1,xp,yp);
[thptB,rptB]=cart2pol(yB,xB); [thptA,rptA]=cart2pol(yA,xA); [thptC,rptC]=cart2pol(yC,xC);
%on plot en polaire
subplot(3,1,1)
ax1=axes('visible','off'); pcolor(xp,yp,zp1); shading flat; colorbar; axis equal ax2 = axes('position', get(ax1, 'position'));
%Traçons les coordonnees dans le plan polaire
hp=mmpolar(thptB,rptB,thptA,rptA,thptC,rptC,'Rlimit',[0,100],'backgroundcolor','none'); set(ax1, 'visible', 'off'); set(hp,'linestyle','none'); set(hp,'markersize',10); set(hp,{'color'},{'c';'y';'g'}) set(hp, {'markeredgecolor', 'marker'}, {'c' 'o'; 'y' '^';'g' 's'}); set(hp,{'markerfacecolor'},{'c';'y'; 'g'}) legend('Bob','Alice','Charlie') title('Distribution polaire')
subplot(3,1,2)
zp2=interp2(Xeve,Yeve,PerrE2,xp,yp);
ax1=axes('visible','off'); pcolor(xp,yp,zp2); shading flat; colorbar; axis equal ax2 = axes('position', get(ax1, 'position'));
hp=mmpolar(thptB,rptB,thptA,rptA,thptC,rptC,'Rlimit',[0,100],'backgroundcolor','none'); set(ax1, 'visible', 'off'); set(hp,'linestyle','none'); set(hp,'markersize',10); set(hp,{'color'},{'c';'y';'g'}) set(hp, {'markeredgecolor', 'marker'}, {'c' 'o'; 'y' '^';'g' 's'}); set(hp,{'markerfacecolor'},{'c';'y'; 'g'}) legend('Bob','Alice','Charlie') title('Distribution polaire')
subplot(3,1,3)
zp3=interp2(Xeve,Yeve,PerrE3,xp,yp);
ax1=axes('visible','off'); pcolor(xp,yp,zp3); shading flat; colorbar; axis equal ax2 = axes('position', get(ax1, 'position'));
hp=mmpolar(thptB,rptB,thptA,rptA,thptC,rptC,'Rlimit',[0,100],'backgroundcolor','none'); set(ax1, 'visible', 'off'); set(hp,'linestyle','none'); set(hp,'markersize',10); set(hp,{'color'},{'c';'y';'g'}) set(hp, {'markeredgecolor', 'marker'}, {'c' 'o'; 'y' '^';'g' 's'}); set(hp,{'markerfacecolor'},{'c';'y'; 'g'}) legend('Bob','Alice','Charlie') title('Distribution polaire')

채택된 답변

Kelly Kearney
Kelly Kearney 2014년 6월 6일
The axes command creates a new axis, and if you don't specify a position, it assumes the default position in the center of the figure. So each time you issue these commands:
subplot(3,1,1)
ax1=axes('visible','off'); pcolor(xp,yp,zp1); % etc ...
you create a subplot, then create a new (invisible) full-figure, centered axis. The centered axis, being the most recently created, is set as the current axis for all subsequent plotting commands.
What you want instead is:
ax1 = subplot(3,1,1)
set(ax1, 'visible','off'); pcolor(xp,yp,zp1); % etc ...
  댓글 수: 1
Stanislav Stefanovski
Stanislav Stefanovski 2014년 6월 6일
Thank you very much! It seems that coffee dosen't work this morning because when I read your answer, I remembered that you gave me the same method few weeks ago. Anyway, now it pops me what I want.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Subplots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by