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

6 件のコメント

Image Analyst
Image Analyst 2011 年 11 月 16 日
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 2011 年 11 月 16 日
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 2011 年 11 月 16 日
編集済み: Image Analyst 2025 年 11 月 13 日
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 2011 年 11 月 16 日
@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 2011 年 11 月 16 日
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 2011 年 11 月 16 日
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 件のコメント

Fangjun Jiang
Fangjun Jiang 2011 年 11 月 16 日
Interesting hadamard() function!
Arundhatee Talukdar
Arundhatee Talukdar 2011 年 11 月 16 日
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 ExchangeCreating, Deleting, and Querying Graphics Objects についてさらに検索

タグ

質問済み:

2011 年 11 月 16 日

編集済み:

2025 年 11 月 13 日

Community Treasure Hunt

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

Start Hunting!

Translated by