How to create several figures in a subplot with different axes
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuestas (2)
Scott MacKenzie
el 9 de Jun. de 2021
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 comentarios
Ver también
Categorías
Más información sobre Line Plots en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!