Tak
Tak

Reputation: 3616

Color bar positioning in Matlab

I'm using the below code to display one bar for 3 figures. I'm asking if anyone could assist me to make the bar horizontal not vertical? So that instead the bar comes vertical on the right end, I want it horizontal on the bottom starting from the first figure to the last one.

this is the code I'm using:

ax(1)=subplot(1,3,1);
ax(2)=subplot(1,3,2);
ax(3)=subplot(1,3,3);
h=colorbar;
set(h, 'Position', [.9 .11 .05 .8150]);
for i=1:3
pos=get(ax(i), 'Position');
set(ax(i), 'Position', [pos(1) pos(2) 0.8*pos(3) pos(4)]);
end;

Upvotes: 0

Views: 18031

Answers (1)

Tak
Tak

Reputation: 3616

I was able to solve it using:

h=colorbar('SouthOutside');
set(h, 'Position', [.1 .05 .8150 .05]);
for i=1:3
pos=get(ax(i), 'Position');
set(ax(i), 'Position', [pos(1) 0.1+pos(2) pos(3) 0.8*pos(4)]);
end;

Upvotes: 2

Related Questions