How to create several figures in a subplot with different axes
조회 수: 3 (최근 30일)
이전 댓글 표시
Dear all,
I'm trying to create a subplot with 7lines and 1 column that plot all of my results consecutivelly.
I have this piece of code:
subplot(7,1,k);
ax1=axes;
imagesc(ax1,Xv,Yv,M);
set(gca,'YDir','normal');
h=colorbar;
ylabel(h,'TOTAL Sound Pressure Level (dB)');
clear title
title(strcat('SPL Broadband\_', listofpercentis(k)));
xlabel('LONGITUDE');
ylabel('LATITUDE');
axis tight;
clear title
ax2=axes;
contourf(ax2,lon_km,lat_km,elevation', [0 0]);
linkaxes([ax1,ax2]);
ax2.Visible = 'off';
ax2.XTick = [];
ax2.YTick = [];
set([ax1,ax2],'Position',[.17 .11 .685 .815]);
ax2.Visible = 'on';
ax2.Visible = 'off';
cb1 = colorbar(ax1,'Position',[.865 .112 .04 .815]);
ylabel(cb1, 'SPL (dB)','FontSize',12);
%AUTOMATIC WAY
% xlim([ax1,ax2],[xmin xmax]);
% ylim([ax1,ax2],[ymin ymax]);
axes(ax1); axis equal;
axes(ax2); axis equal;
hold on;
%plot(km2deg(Sx),km2deg(Sy), '*k')
%plot(-9,37.96, 'Ok');
%source=text(deg2km(-8.99),deg2km(37.94),'source','FontSize',12)
portugal=text(deg2km(-8.65),deg2km(37.86),'Portugal','FontSize',20);
set(portugal,'Rotation',90);
sines=text(deg2km(-8.869),deg2km(37.96),'*Sines','FontSize',14);
caxis(ax1,[0 200]);
The problem is that all plots are displayed in the same position and I want to display the first plot in the first line, the second plot in the second line, etc etc.
Thanks in advance,
댓글 수: 0
답변 (2개)
Scott MacKenzie
2021년 6월 9일
You're aren't using subplot correctly. For each plot you need a separate call to subplot with the index (in your case, row) where you want the plot to appear:
subplot(7,1,1);
plot ... % something in the 1st row
subplot(7,1,2);
plot ... % something in the 2nd row
subplot(7,1,3);
plot ... % something in the 3rd row
...
Type doc subplot in the MATLAB's command window for more explanation and examples
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Line Plots에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!