Label rows and columns of subplots
27 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
I have six figures (in .fig format) and would like to arrange them in a 2x3 subplot and then label each row and column of subplots. In specific, I want to label the two rows 'Participant 1' and 'Participant 2', and the three columns 'Frequency set 1', 'Frequency set 2' and 'Frequency set 3'.
Below is the code I tried:
% give the path of .fig to be plotted together
figName1 = '/.../participant1/freqSet1.fig';
figName2 = '/.../participant1/freqSet2.fig';
figName3 = '/.../participant1/freqSet3.fig';
figName4 = '/.../participant2/freqSet1.fig';
figName5 = '/.../participant2/freqSet2.fig';
figName6 = '/.../participant2/freqSet3.fig';
% list all variables starting w/ 'figName'
figList = who('figName*');
% Load saved figures
fig1=hgload(figName1);
fig2=hgload(figName2);
fig3=hgload(figName3);
fig4=hgload(figName4);
fig5=hgload(figName5);
fig6=hgload(figName6);
% Prepare subplots
figure
for iSubPlot = 1:length(figList)
h(iSubPlot) = subplot(2,3,iSubPlot);
if iSubPlot==1
text(-0.35, 0.5,'Participant 1');
text(0.35,1.1,'Frequency set 1');
elseif iSubPlot==2
text(0.35,1.1,'Frequency set 2');
elseif iSubPlot==3
text(0.35,1.1,'Frequency set 3');
elseif iSubPlot==4
text(-0.35, 0.5,'Participant 2');
end
end
% now the desired labels have been applied
% Paste figures on the subplots
copyobj(allchild(get(fig1,'CurrentAxes')),h(1));
copyobj(allchild(get(fig2,'CurrentAxes')),h(2));
copyobj(allchild(get(fig3,'CurrentAxes')),h(3));
copyobj(allchild(get(fig4,'CurrentAxes')),h(4));
copyobj(allchild(get(fig5,'CurrentAxes')),h(5));
copyobj(allchild(get(fig6,'CurrentAxes')),h(6));
% now the subplots are pasted, the previous row and column labels are gone
As described in the code comments, the row and column lables disappear after I paste the figures into the subplot. Do you know how I can fix this? Thanks very much!
5 Commenti
Koundinya
il 10 Dic 2018
Tried this in R2015a and R2017a, the labels are intact. In your case ,maybe the labels are not visible because they are being obstructed by the figures ?
Risposte (0)
Vedere anche
Categorie
Scopri di più su Axis Labels in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!