How to get rid of the black lines at the edge of each changing color?

6 个评论

I'm curious why you're using pcolor() at all. Tell me why you're using that, which has one less "pixel" in each direction than the array you're trying to display, instead of the more conventional imshow(), image(), or imagesc(). I've not been able to figure out or hear why anyone would want to use that to display a 2D array, such as one that represents an image.
I am trying to plot some data Z over the meshgrid(1:180, 1:180). And I quite dont understand the parameter of ismhow or the function itself.
Here's an illustration for you. Run this code:
m =[...
2 3 3 1
2 2 1 1
3 3 3 1
2 1 3 3] % Define a 4x4 matrix
m = 4×4
2 3 3 1 2 2 1 1 3 3 3 1 2 1 3 3
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
pcolor(m) % Shows 3x3, not 4x4 as most people would expect.
colorbar
Now, how many elements do you see? Were you expecting to see 4 by 4? Were you expecting to see that every "1" had the same color, every "2" had the same color, and every "3" had the same color? If your answers are yes, then you can see that it doesn't give you what you were expecting at all, and you should learn how to use imshow() - it's really not that hard, it's not. You don't have to use most of the optional input arguments.
imshow(m, [], 'InitialMagnification', 3000);
axis('on', 'image'); xticks(1:4); yticks(1:4);
colormap(parula(3))
colorbar
The image above has 4 by 4 pixels/blocks as expected, and the brightnesses of the pixels correspond to the values in the 4x4 m matrix.
@Image Analyst: Pcolor is much more useful than imagesc when your data array isn't one that represents an image, e.g. a dataset on an uneven or non-rectilinear grid. Also, why do you imply that in the example above identical data values would be mapped to different colors with pcolor? The dropped-edge cell, I concede, is a little annoying, though I usually circumvent that with NaN-padding.
Kelly, pcolor does color interpretation for the faces according to the colors of the vertices (which are not drawn), so the color of any one face is not directly associated with a single point value and instead is an interpolation according to what is nearby.
That's true only if the shading scheme is set to interpolated. Otherwise, the color is associated with a single vertex, and in Image Analyst's example, each cell with a 1 in its upper right corner is indeed the same color as other 1-cells, regardless of its neighbors.

请先登录,再进行评论。

回答(2 个)

Jonathan
Jonathan 2011-11-16

2 个投票

hand = pcolor(hadamard(20))
set(hand, 'linestyle', 'none')

3 个评论

Interesting hadamard() function!
I am using pcolor(X,Y, Z)
In that case, how I do this?
Jonathan
Jonathan 2011-11-16
hand = pcolor(X,Y, Z)
set(hand, 'linestyle', 'none')

请先登录,再进行评论。

Kelly Kearney
Kelly Kearney 2011-11-16

1 个投票

Alternatively
pcolor(X,Y,Z);
shading flat;

类别

帮助中心File Exchange 中查找有关 Creating, Deleting, and Querying Graphics Objects 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by