How to understand C in pcolor? Why are specific colours not other colours coming out of certain numbers?

1 次查看(过去 30 天)
Hi,
I'm struggling to understand C in pcolor.
From the official website,
it says 'MATLAB® creates a pseudocolor plot using each set of four adjacent points in C to define a surface rectangle (i.e., cell)'.
What is the relationship (conversion) between these 4 points and a colour?
To make a simple example to represent my question, please see below:
C = [ 0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0 ];
pcolor(C)
It plot something like below, but WHY GREEN? Why this green, not a darker green or lighter green? How the C ended up with a green?
This green must have its RGB values. How is C related to those RGB values? Please help. I'm so lost here.
untitled.jpg

回答(1 个)

Walter Roberson
Walter Roberson 2019-3-6
If you had provided an X and Y grid, then it would be using bilinear interpolation. Since you did not provide a grid, the effect is the same as plain mean() of the four corners.
Once the mean is determined, the value goes through color mapping. If the value is less than the first element of the axes CLim, then it is mapped to the first color in the color map. If it is greater than the last element of the axes CLim then it is mapped to the last element in the colormap. Otherwise it is mapped to (value - CLim(1))/(CLim(end)-CLim(1)) * number of colormap entries -- so proportion of the color range maps to proportion of the color map as an index.
Why that shade of green? Because that is what happens to get looked up in your active colormap. If you were to colormap() a different colormap then it would change.

类别

Help CenterFile Exchange 中查找有关 Colormaps 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by