Need help regarding colorbar?
19 ビュー (過去 30 日間)
古いコメントを表示
I want to create a colorbar with three colors: blue color for minimum( it will be negative), white color for zero(in the middle) and red color for maximum(it will be positive). I want the colorbar to transform smoothly between the three colors. Any suggestions?
2 件のコメント
Rik
2018 年 6 月 17 日
Create a colormap that is sufficiently smooth to your liking (e.g. with a few calls to linspace). Then you can set the Ticks property and the TickLabels property. The nice thing for you is that if you choose your scale sufficiently small, all negative values will be below the lowest index (and be colored with the lowest index), and all positive values will be above the highest index (which will be colored with the highest index). That would leave only 0 itself to be colored white.
You should supply a MWE, so we can help you tweak your code to solve this for realistic values. (Use the {}Code button to correctly format your code.)
採用された回答
Ameer Hamza
2018 年 6 月 18 日
If you want white color exactly at the center corresponding to value 0 then you will need to make the limit of caxis() symmetrical around zero. I suppose that in your case min value is negative. Therefore try
maxLimit = max(abs(min), abs(max));
caxis([-maxLimit maxLimit]);
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Color and Styling についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!