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

6 comentarios

Image Analyst
Image Analyst el 16 de Nov. de 2011
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.
Arundhatee Talukdar
Arundhatee Talukdar el 16 de Nov. de 2011
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.
Image Analyst
Image Analyst el 16 de Nov. de 2011
Editada: Image Analyst el 13 de Nov. de 2025
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.
Kelly Kearney
Kelly Kearney el 16 de Nov. de 2011
@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.
Walter Roberson
Walter Roberson el 16 de Nov. de 2011
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.
Kelly Kearney
Kelly Kearney el 16 de Nov. de 2011
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.

Iniciar sesión para comentar.

Respuestas (2)

Jonathan
Jonathan el 16 de Nov. de 2011

2 votos

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

3 comentarios

Fangjun Jiang
Fangjun Jiang el 16 de Nov. de 2011
Interesting hadamard() function!
Arundhatee Talukdar
Arundhatee Talukdar el 16 de Nov. de 2011
I am using pcolor(X,Y, Z)
In that case, how I do this?
Jonathan
Jonathan el 16 de Nov. de 2011
hand = pcolor(X,Y, Z)
set(hand, 'linestyle', 'none')

Iniciar sesión para comentar.

Kelly Kearney
Kelly Kearney el 16 de Nov. de 2011

1 voto

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

Categorías

Más información sobre Creating, Deleting, and Querying Graphics Objects en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 16 de Nov. de 2011

Editada:

el 13 de Nov. de 2025

Community Treasure Hunt

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

Start Hunting!

Translated by