User defined colorbars in a plot

5 Ansichten (letzte 30 Tage)
RN
RN am 4 Feb. 2020
Beantwortet: RN am 5 Feb. 2020
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.

Antworten (2)

Walter Roberson
Walter Roberson am 4 Feb. 2020
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 am 5 Feb. 2020
Oops, My mistake.
Please find attachment here.
Please provide the code to generate similar colorbar for any 2D scatter plot.

Kategorien

Mehr zu Color and Styling finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by