Reverse the colorbar axis

216 ビュー (過去 30 日間)
Claire
Claire 2012 年 4 月 30 日
コメント済み: prio 2018 年 4 月 1 日
I have a contourf plot, which I plotted across the range 2 to -2. I have edited the colormap to get it to move between green and brown.
I don't want to change the colormap, or the values that are associated with each color. All I want to do is essentially flip the colorbar, so that -2 is at the top, and 2 is at the bottom.
All the solutions I have found so far only flip the colors, which is not what I want to do.
I'm basically looking for an equivalent function to: set(gcf,'YDir','reverse') but for the colorbar.
I'd appreciate any help I can get. Cheers, Claire.
  1 件のコメント
Cody Webb
Cody Webb 2015 年 10 月 25 日
How did you flip just the colors and not the axis?

サインインしてコメントする。

採用された回答

Geoff
Geoff 2012 年 4 月 30 日
The call to colorbar returns a handle. There's lots of options in there to set, and you'll find the one you wanted, too.
h = colorbar;
set( h, 'YDir', 'reverse' );
  4 件のコメント
Germano Scarabelli
Germano Scarabelli 2015 年 1 月 8 日
thanks! I spent a lot of time trying to reverse it!
prio
prio 2018 年 4 月 1 日
Thanks a lot!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeColormaps についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by