フィルターのクリア

How To Create A Custom Colorbar

153 ビュー (過去 30 日間)
Ryan
Ryan 2015 年 8 月 7 日
回答済み: Ghada Saleh 2015 年 8 月 10 日
I'm trying to customize a colorbar on a contoured image I am producing. I would like custom intervals with different colors between each interval. Below are a few lines of how I tried to generate such a colorbar but with no success.
contourfm(lats,lons,data,[0 25 50 75 125 150 200 300 400]);
c = colorbar;
c.Label.String = titl;
c.Limits = [minC 500];
c.Ticks = [0 25 50 75 125 150 200 300 400];
limits = c.Limits;
cInt = linspace(limits(1),limits(2),64);
cmap = flipud(jet);
Below is an example of how I am trying to make rainfall <25% of normal a yellow/orange color. I do similar iterations for 25-50% of normal, etc..
in1 = find(cInt <= 25);
nin1 = length(in1);
for i=1:nin1
cmap(in1(i),:) = [1 0 0]; %[0.9937,0.7454,0.2403];
end
This code however is not getting me the desired results.

回答 (1 件)

Ghada Saleh
Ghada Saleh 2015 年 8 月 10 日
Hi Ryan,
I understand that you want to map different data intervals to different colors. One way of doing that is to add colorbar to the graph interactively. That link illustrates how to interactively map different data values into the colormap.
If you want to do that in a programmatic manner, the following link contains an example to changing mapping of data values into the colormap.
I hope this helps,
Ghada

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by