I have a colormap as below:
cmap=[0.729 0.752 0.7529;
0.5689 1 1;
0.6078 0.8039 1;
0.3255 0.6627 1;
0 0.4745 0.949;
0.7067 1 0.2844;
0.4756 0.8431 0;
0 0.6588 0;
0 0.502 0;
0 0.3333 0;
1 1 0;
0.9961 0.7686 0.4196;
0.9765 0.6392 0.2667;
1 0.3922 0.102;
0.8 0 0;
1 0 1]
I want to specify a range to the color map as it is done in the figure: Since the last range is not equal to the other i cannot use caxis([cmin cmax]); How can I define the range for each color in showing an image?

 Akzeptierte Antwort

Stephen23
Stephen23 am 2 Okt. 2016
Bearbeitet: Stephen23 am 2 Okt. 2016

0 Stimmen

You need to create a linear correspondence between the colormap intervals and the desired data intervals. You basically have two choices:
  1. interpolate that colormap so that it has more colors and those color division occur exactly at the data intervals that you want.
  2. adjust the data so that it corresponds linearly to the given colormap. Commands such as mesh support this by an optional input argument, often named C.
Not ideal, and it would be nice to have that ability to specify the intervals...
Note that MatPlotLib does have this ability, if you are really need this.

2 Kommentare

midia yousefi
midia yousefi am 2 Okt. 2016
Bearbeitet: Stephen23 am 2 Okt. 2016
Thanks I have create the correspondence between colormap and data matrix as below:
colormap(cmap1)
colors=zeros(size(desired_point));
colors(desired_point>=-10 & desired_point<8)=1;
colors(desired_point>=8 & desired_point<12)=2;
colors(desired_point>=12 & desired_point<16)=3;
colors(desired_point>=16 & desired_point<20)=4;
colors(desired_point>=20 & desired_point<24)=5;
colors(desired_point>=24 & desired_point<28)=6;
colors(desired_point>=28 & desired_point<32)=7;
colors(desired_point>=32 & desired_point<36)=8;
colors(desired_point>=36 & desired_point<40)=9;
colors(desired_point>=40 & desired_point<44)=10;
colors(desired_point>=44 & desired_point<48)=11;
colors(desired_point>=48 & desired_point<52)=12;
colors(desired_point>=52 & desired_point<56)=13;
colors(desired_point>=56 & desired_point<60)=14;
colors(desired_point>=60 & desired_point<64)=15;
colors(desired_point>=64 & desired_point<=68)=16;
mesh(x_pixle,y_pixle,desired_point,colors)
colorbar
but the result is not correct. this is the image:
as you see the color assigened to value of the point is not correct.
Stephen23
Stephen23 am 2 Okt. 2016
Bearbeitet: Stephen23 am 3 Okt. 2016
Can you please upload your data by editing your question and clicking the paperclip button.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by