
I see a bug in pcolor
1 view (last 30 days)
Show older comments
Mark Mendlovitz
on 21 Oct 2022
Commented: Steven Lord
on 22 Oct 2022
C = eye(10);
pcolor(C)
colormap summer
This example, which comes straight out of the documentation, produces a 9 x 9 colored block matrix, not a 10 x 10 matrix. This is a bug.
0 Comments
Accepted Answer
Image Analyst
on 21 Oct 2022

It's not a bug - it's a feature. That's why I never use pcolor. I use imshow instead, which shows every pixel.
m = magic(3) % Create a 3-by-3 matrix
subplot(2, 1, 1);
pcolor(m)
title('pcolor');
subplot(2, 1, 2)
imshow(m, []);
title('imshow');
Note that pcolor has the vertices (where the black lines are) be the value of the pixel, not the value of the tiles.
I suggest that you use imshow or image or imagesc, with the colormap option if you want a colormap.
3 Comments
Steven Lord
on 22 Oct 2022
As another analogy, this time in 1 dimension: it's the fence post versus fence rail problem. If you want to create a fence with two segments you need three posts, with the first rail segment being between posts 1 and 2 and the second between posts 2 and 3. The image-related functions let you say what color the rails are. The pcolor function lets you specify the color of the posts and colors the rails with the color of the post where they start. The color of the last post (or the last row/column in the pcolor case) doesn't affect the color of any rail.
More Answers (0)
See Also
Categories
Find more on Red 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!