I am trying use pcolor, but I do not understand how pcolor works.
First, I read the description in the above link.
X = [1 2 3; 1 2 3; 1 2 3];
Y = X';
mymap = [1 0 0; 0 1 0; 0 0 1; 1 1 0; 0 0 0];
C = [3 4 5; 1 2 5; 5 5 5];
It's written that "The color of a face depends on the color at one of its four vertices. Because of this relationship between the vertex colors and face colors, none of the values in the last row and column of C are represented in the plot."
Therefore, I thought only elements C(1,1), C(1,2), C(2,1) and C(2,2) do matter. The elements C(1,3), C(2,3), C(3,1), C(3,2), C(3,3) do no matter, so I can put any arbitrary number in these places to produce the same image above.
Second, I read the description in the above link.
It’s written that “To create a custom colormap, specify map as a three-column matrix of RGB triplets where each row defines one color. An RGB triplet is a three-element row vector whose elements specify the intensities of the red, green, and blue components of the color.”
Therefore, I thought first row [1 0 0] of mymap designates red, and the second row [0 1 0] designates green, and the third row [0 0 1] designates blue, and the fourth row [1 1 0] designates yellow, and the fifth row [0 0 0] designates black. For example, C(1,1)=3 designates the third row of mymap, which is blue. C(2,2)=2 designates second row of mymap, which is green.
Then, based on my understanding, I tried to plot a simple square with a specific color I want.
X = [0 1; 0 1];
Y = [0 0; 1 1];
mymap = [1 0 0; 0 0 0];
C = [1 1 ; 1 1];
pcolor(X, Y, C)
Based on my understanding, only one element of matrix C would be represented in the plot, and the remaining three elements do not matter. Since all elements are 1, it designates first row of mymap, which is red.
However, it plots a black square, which is not what I expected.
Based on my understanding, the color matrix C must have only positive integers as its elements, since it should designate specific row of mymap. However, C = [1.4 1.7 ; 1.2 0.1] does not provide any error, and it plots a black square again.
Basically, I do not understand how pcolor, color matrix, and colormap work. I have been Googling for a full day, but I have not understood yet, which is very frustrating. Please help me.