How to flip x & y axes of a colorbar

5 vues (au cours des 30 derniers jours)
John Trimper
John Trimper le 30 Oct 2014
Modifié(e) : John Trimper le 30 Oct 2014
I want to put a colorbar in a figure and have the colorbar horizontally span the length of 3 subplots underneath them. How can I do this and have the colorbar values scale horizontally instead of vertically?
myfig=figure;
subplot(1,3,1);
sp1=plot(1,1,'o', 'markersize', 40, 'markerfacecolor', 'b');
set(gca, 'visible', 'off');
subplot(1,3,2);
sp2=plot(1,1,'o', 'markersize', 40, 'markerfacecolor', 'g');
set(gca, 'visible', 'off')
subplot(1,3,3);
sp3=plot(1,1,'o', 'markersize', 40, 'markerfacecolor', 'r');
set(gca, 'visible', 'off')
colbar=colorbar('Position', [.25 .1 .5 .05]);
colormap jet
I know I could set the colorbar to be 'south' of subplot 2, but then it won't be as wide as I want.

Réponses (1)

John Trimper
John Trimper le 30 Oct 2014
Modifié(e) : John Trimper le 30 Oct 2014
I was able to do it by making a colorbar 'south' of the 2nd subplot, then changing the position.
So, problem solved, but if anyone knows how to flip the x & y axes of a colorbar without setting the 'location' to 'south' or 'north', that'd be appreciated.
myfig=figure;
subplot(1,3,1);
sp1=plot(1,1,'o', 'markersize', 40, 'markerfacecolor', 'b');
set(gca, 'visible', 'off');
subplot(1,3,2);
sp2=plot(1,1,'o', 'markersize', 40, 'markerfacecolor', 'g');
set(gca, 'visible', 'off')
colbar=colorbar('Location', 'south', 'Position', [.25 .1 .5 .05]);
subplot(1,3,3);
sp3=plot(1,1,'o', 'markersize', 40, 'markerfacecolor', 'r');
set(gca, 'visible', 'off')

Catégories

En savoir plus sur White dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by