Colorbar with three colors

9 ビュー (過去 30 日間)
Yunhui He
Yunhui He 2017 年 10 月 3 日
回答済み: KSSV 2017 年 10 月 3 日
I am using surf plot the pictures. I want to see the colorbar at the right-hand side. But the transition of the color is not so obvious. I want to see from green to red, and there is another color in the middle. How can I do this?
Thanks!
  1 件のコメント
Walter Roberson
Walter Roberson 2017 年 10 月 3 日
Are there only 3 colors in the plot, or is it that you only want three colors to appear in the colorbar ?
If you are already doing colormap() in order to activate a colormap of three colors, then colorbar() should adjust automatically.

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

採用された回答

KSSV
KSSV 2017 年 10 月 3 日
Z = peaks(100) ;
surf(Z)
shading interp
cmap = [1 0 0 ; 0 1 0 ; 0 0 1] ;
colorbar
colormap(cmap)

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeColor and Styling についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by