Create Custom ColourBar

Hello!)
I wonder if this can be done in Matlab. I have three variables...for example as follows:
A=0 B=300 C=1000
Variable B always lies between A and C.....I wonder if it can be possible to add a colourbar to an existing chart in such a way that the A and C define minimum and maximum of the colourbar, while point B will define how much of the color bar will be colored in the colors which correspond to A and C....for example in the above case,
if A is Red and C is Black....the color bar would look in such a way so that the Red color would fade into white in the first 30% of the color bar (till point B, 300)....I will also need to label that point B on the color continuum...(30% of the A to D distance from point A and 70% distance from point D)
I will be happy to hear any suggestion.
Thanks!)
D

回答 (2 件)

Fangjun Jiang
Fangjun Jiang 2011 年 10 月 14 日

1 投票

colormap()
caxis()
Something like this?
Red=1:-0.01:0;
Green=zeros(size(Red));
Blue=zeros(size(Red));
MyColor=[Red;Green;Blue]';
Data=1:10:1001;
pcolor([Data;Data]);
colormap(MyColor);
caxis([1 1000]);
colorbar;

2 件のコメント

Dima
Dima 2011 年 10 月 14 日
thanks but I am not sure how to apply this to this question....Maybe you can help me with this??? you were kind to introduce me to Matlab before and I am able to do a few things now but at a loss as to how this can be done.
Fangjun Jiang
Fangjun Jiang 2011 年 10 月 16 日
See the example in my answer.

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

Image Analyst
Image Analyst 2011 年 10 月 15 日

0 投票

Try linspace(). Write back if you can't figure it out.

カテゴリ

タグ

質問済み:

2011 年 10 月 14 日

Community Treasure Hunt

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

Start Hunting!

Translated by