User defined colorbars in a plot

10 次查看(过去 30 天)
RN
RN 2020-2-4
回答: RN 2020-2-5
Hello,
I need a colourbar as shown in the attachment.
Color changes
from light red to red for 1 to 10;
from red to yellow for >10 to 100;
yellow to light green than light blue for 100 to 1000
and ends with dark blue for 2048.
How to achieve this predefined colorbar? Any suitable cmap that can give similar colorbar.

回答(2 个)

Walter Roberson
Walter Roberson 2020-2-4
Note that the positions needed there are in the range 0 to 1, so you would need to divide your values by 2048 for this purpose. However, that will not matter for later as you can caxis([1 2048]); colormap(TheCustomMap)
Caution: sufficiently old MS WIndows are restricted to 256 colors in a colormap, but you need 1024 positions (you do not need 2048 positions because each of your bins can be data width 2.) If you could fudge the boundaries to 16 and 128 then you could reduce the number of colormap entries needed.

RN
RN 2020-2-5
Oops, My mistake.
Please find attachment here.
Please provide the code to generate similar colorbar for any 2D scatter plot.

类别

Help CenterFile Exchange 中查找有关 Color and Styling 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by