How to customize a colormap?

31 ビュー (過去 30 日間)
Leon
Leon 2022 年 7 月 30 日
コメント済み: Star Strider 2022 年 7 月 30 日
I'm plotting a parameter with a range of 0 to 6. Several of my collaborators have been suggesting to create a colormap to go from red to blue at 1 (the critical point <1 means undersaturated, and >1 means supersaturated) to better illustrate the point.
I wonder what's the best way to achieve this within Matlab?
  2 件のコメント
Walter Roberson
Walter Roberson 2022 年 7 月 30 日
Leon
Leon 2022 年 7 月 30 日
Many thanks for sharing the link. I'll take a look at it soon.

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

採用された回答

Star Strider
Star Strider 2022 年 7 月 30 日
Another option —
cm = colormap(turbo(6));
cm = colormap(flipud(turbo(6))); % Optional
cb = colorbar;
cbtix = cb.Ticks;
cb.Ticks = linspace(min(cbtix), max(cbtix), 7);
cb.TickLabels = 0:6;
The turbo colormap was introduced in R2020b.
I am not certain how you want it oriented, so use the flipud function to reverse the direction of the colours (as I did here), if necessary.
.
  6 件のコメント
Leon
Leon 2022 年 7 月 30 日
Many thanks for the explanation!
Star Strider
Star Strider 2022 年 7 月 30 日
As always, my pleasure!

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

その他の回答 (0 件)

カテゴリ

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

タグ

製品


リリース

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by