How to set manual values for colorbar

7 ビュー (過去 30 日間)
Ihiertje
Ihiertje 2016 年 10 月 31 日
回答済み: LauraLee Austin 2016 年 10 月 31 日
Hi,
I want to create an colorbar with three colors (red, yellow, green) and I want to set the values for these colors.
For example:
Red = 100 to max value image
Yellow = 50-100
Green - 0-50
Can someone help me how to set the values for the colors manually.
Thanks!
  1 件のコメント
Alexandra Harkai
Alexandra Harkai 2016 年 10 月 31 日
This looks similar: Customize a colormap

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

回答 (1 件)

LauraLee Austin
LauraLee Austin 2016 年 10 月 31 日
Let's assume the max value is 128 and your data is in a matrix X. I'm going to modify a demo file of earth to have values greater than 100 for this example.
m=128; % set max value
c=zeros(m,3); % start with all 0's
c(1:50,2)=1; %green
c(100:128,1)=1; %red
c(51:99,1)=1; %yellow
c(51:99,2)=1; %yellow
load earth
X=X*2;
image(X)
colormap(c)
colorbar

カテゴリ

Help Center および File ExchangeColor and Styling についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by