Set ratio on subplot after resizing window
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi all,
Since I don't know how to do a few things (like putting lines on the title of subplots), I'm using some annotation stuff, getting the generated code and pasting it on my regular plots. The catch is: the annotations only get to the right places when I maximize the window, but that makes a previously almost square subplot become a rectangle. I need it to be a square (same dimensions on X and Y) on the final figure. How can I arrange that?
For instance, my code is something like this:
titulo{1} = 'I';
titulo{2} = 'II';
titulo{3} = 'III';
titulo{4} = 'IV';
figure
cmapInt = [1, 0, 0; 1, 1, 1; 0, 0, 1];
cmapPlot = [
1 0 0
0 0.7 0
0 0 0.9
0.5 0.5 0.5];
aMax = 4;
%%matrizes de interação
position = [1 5 9 13];
for a = 1:aMax
subplot(4,4,position(a)),...
imagesc(rand(50).*(ceil(rand(50)*3)-2)
colormap(cmapInt)
caxis([-1 1])
xlim([1 50])
ylim([1 50])
title(titulo{a})
set(get(gca, 'Title'), 'Color', cmapPlot(a,:), 'FontWeight','bold');
h = get(gca, 'Title');
set(h, 'Units', 'normalized');
set(h, 'Position', [0,1,0]);
set(h, 'HorizontalAlignment', 'left');
set(h, 'VerticalAlignment', 'bottom');
if a == 4
xlabel('Espécie')
end
end
% Red line
annotation('rectangle',...
[0.14771875 0.935672514619882 0.12665625 0.00584795321637261],...
'FaceColor',[1 0 0],...
'Color',[1 0 0]);
% Green line
annotation('rectangle',...
[0.14771875 0.49508771929824 0.12665625 0.00584795321637261],...
'FaceColor',[0 0 1],...
'Color',[0 0 1]);
% Blue line
annotation('rectangle',...
[0.14771875 0.716842105263155 0.12665625 0.00584795321637261],...
'FaceColor',[0 0.498039215686275 0],...
'Color',[0 0.498039215686275 0]);
% Gray line
annotation('rectangle',...
[0.14771875 0.276315789473684 0.12665625 0.00584795321637261],...
'FaceColor',[0.501960784313725 0.501960784313725 0.501960784313725],...
'Color',[0.501960784313725 0.501960784313725 0.501960784313725]);
%%curvas de perda de diversidade funcional
for a = 1:4
hold on
subplot(4,4,[2 16]), ...
plot(rand(1,50),...
'Color', cmapPlot(a,:))
box off
end
hold on
subplot(4,4,[2 16]), ...
plot(rand(1,50)*2, '--black')
box off
xlabel('Extinções')
ylabel('Grupos Remanescentes')
Thanks!
0 Kommentare
Antworten (0)
Siehe auch
Kategorien
Mehr zu Subplots finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!