How can I modify my subplot positions to stop them overlapping each other?
Mostra commenti meno recenti
I am trying to create a subplot (2 plots) of maps next to each other , and my issue is with my placement of subplots: They are overwriting each other.
How can I modify the plot positions so they won't overwrite each other?
The code I'm using is:
%% Plot #1
figure; subplot(1,2,1)
% Main plot
contourf(XMesh1,YMesh1,ZMesh1,10000,'EdgeColor','none')
xlabel('X (Degree)'); ylabel('Y (Degree)')
ax1.Position=[0.1,0.1,0.6,0.6];
ax1.TickDir='out';
% X Axis histogram
ax2=axes('Parent',gcf);hold(ax2,'on')
[f,xi]=ksdensity(X_GS);
fill([xi,xi(1)],[f,0],[0.34 0.47 0.71],'FaceAlpha',...
0.3,'EdgeColor',[0.34 0.47 0.71],'LineWidth',1.2)
ax2.Position=[0.1,0.75,0.6,0.15];
ax2.YColor='none';
ax2.XTickLabel='';
ax2.TickDir='out';
ax2.XLim=ax1.XLim;
% Y Axis histogram
ax3=axes('Parent',gcf);hold(ax3,'on')
[f,yi]=ksdensity(Y_GS);
fill([f,0],[yi,yi(1)],[0.34 0.47 0.71],'FaceAlpha',...
0.3,'EdgeColor',[0.34 0.47 0.71],'LineWidth',1.2)
ax3.Position=[0.75,0.1,0.15,0.6];
ax3.XColor='none';
ax3.YTickLabel='';
ax3.TickDir='out';
ax3.YLim=ax1.YLim;
%% Plot #2
subplot(1,2,2)
% Main plot
contourf(XMesh2,YMesh2,ZMesh2,10000,'EdgeColor','none')
xlabel('X'); ylabel('Y')
ax1.Position=[0.1,0.1,0.6,0.6];
ax1.TickDir='out';
% X Axis histogram
ax2=axes('Parent',gcf);hold(ax2,'on')
[f,xi]=ksdensity(X_G);
fill([xi,xi(1)],[f,0],[0.34 0.47 0.71],'FaceAlpha',...
0.3,'EdgeColor',[0.34 0.47 0.71],'LineWidth',1.2)
ax2.Position=[0.1,0.75,0.6,0.15];
ax2.YColor='none';
ax2.XTickLabel='';
ax2.TickDir='out';
ax2.XLim=ax1.XLim;
% Y Axis histogram
ax3=axes('Parent',gcf);hold(ax3,'on')
[f,yi]=ksdensity(Y_G);
fill([f,0],[yi,yi(1)],[0.34 0.47 0.71],'FaceAlpha',...
0.3,'EdgeColor',[0.34 0.47 0.71],'LineWidth',1.2)
ax3.Position=[0.75,0.1,0.15,0.6];
ax3.XColor='none';
ax3.YTickLabel='';
ax3.TickDir='out';
ax3.YLim=ax1.YLim;
Risposta accettata
Più risposte (1)
Image Analyst
il 9 Lug 2022
Categorie
Scopri di più su Subplots in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
