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

1 view (last 30 days)
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

Answers (1)

Walter Roberson
Walter Roberson on 6 Mar 2019
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.

Categories

Find more on Colormaps in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!