Move subplot title and create colored line beside it.
Ältere Kommentare anzeigen
Hi, all. I have this plot code for visualizing the matrices that originate a curve being ploted. Each matrix is subploted with a title and has it's curve ploted on a same area for all of the curves. Title and curve share the same color (first matrix is red, so it's curve is also red and so on).
However, I'd like to do two things with it:
- Move the title of each matrix to the left upper corner of it.
- Create a line along the rest of the subplot square with the same color as the title.
Any ideas?
Here goes my code, with adaptations for not needing to load results form actual previous computations.
clear
clc
for a = 1:4
acumuladorSIS{4,5,a,1,2} = ceil(rand(50)*3)-2;
acumulador2{4,5,a,1,2} = ceil(rand(1,50)*10);
end
acumulador3{1,1} = ceil(rand(1,50)*10);
QSG = 50;
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;
b = 1; % aleatorização; 1 = não; 2 = sim;
c = 2; % sinal. 1 = +; 2 = -
d = 4; % distribuição de espécies nos grupos
e = 5; % tipo de distribuição de sinais entre espécies
%%matrizes de interação
pos = [1 5 9 13]
for a = 1:aMax
subplot(4,4,pos(a)),...
imagesc(acumuladorSIS{d,e,a,b,c})
colormap(cmapInt)
caxis([-1 1])
xlim([1 sum(QSG)])
ylim([1 sum(QSG)])
title(a)
set(get(gca, 'Title'), 'Color', cmapPlot(a,:));
end
%%curvas de perda de diversidade funcional
for a = 1:4
hold on
subplot(4,4,[2 16]), ...
plot(acumulador2{d,e,a,b,c}),...
'Color', cmapPlot(a,:)
% to-do: ajeitar cores e tipos de linhas
box off
end
hold on
subplot(4,4,[2 16]), ...
plot(acumulador3{1,1}, '--black')
box off
1 Kommentar
Igor de Britto
am 5 Mär. 2012
Antworten (1)
Geoff
am 5 Mär. 2012
I don't know how to answer your 'line' question, but to set the title position do this:
h = get(gca, 'Title');
set(h, 'Units', 'normalized');
set(h, 'Position', [0,1,0]);
set(h, 'HorizontalAlignment', 'left');
set(h, 'VerticalAlignment', 'bottom');
Play around with those position and alignment values to put the test where you want it, whether that's inside or outside the axes etc.
If your line is simply to separate graphs (so titles don't collide with the other plots), then you may want to consider putting the title inside the axis area. You can make it stand out by modifying the FontWeight and FontSize properties.
-g-
1 Kommentar
Igor de Britto
am 6 Mär. 2012
Kategorien
Mehr zu Title finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!