Difference between pcolor and contourf

47 ビュー (過去 30 日間)
David C
David C 2014 年 7 月 6 日
コメント済み: Image Analyst 2015 年 5 月 13 日
I'm trying to understand what the difference is between pcolor and contourf. If I have a 2D data, stored in variable Z, that I would like to plot, is there a difference between:
pcolor(X,Y,Z)
shading flat
AND
contourf(X,Y,Z)
shading flat
?

採用された回答

Image Analyst
Image Analyst 2014 年 7 月 6 日
contourf uses isolines and has uniform colors in between the iso lines. pcolor doesn't do that at all. pcolor, in my opinion is deceptive because it throws away the last row and column and shows you an array (rows-1) by (columns-1). I see virtually no advantage of pcolor over image() or imshow().
  2 件のコメント
David C
David C 2014 年 7 月 7 日
"contourf..has uniform colors in between the iso lines" - you mean contourf interpolates between the isolines right? So it will add a gradient even if my data does not have the gradient?
Image Analyst
Image Analyst 2014 年 7 月 7 日
No. Interpolates means the value changes. What would you get if you did that? You'd get the original image, which you already have. Look at the demos and see that the entire zone between two isolines is the same color - it's uniformly blue or red or whatever. It's not interpolating or changing.

サインインしてコメントする。

その他の回答 (2 件)

Star Strider
Star Strider 2014 年 7 月 6 日
The pcolor function uses the values of the adjacent points to determine the colors of the enclosed cell. So the color is defined by the points enclosing the cell, not the value of the function within the cell. From the documentation for pcolor (where C is its (MxN) matrix argument):
  • A pseudocolor plot is a rectangular array of cells with colors determined by C. MATLAB® creates a pseudocolor plot using each set of four adjacent points in C to define a surface rectangle (i.e., cell).
Give the same data to both pcolor, image and contourf to see the difference.
  3 件のコメント
Image Analyst
Image Analyst 2014 年 7 月 17 日
To make up for that, I gave him 2 points by voting for it. You can also vote in addition to accepting (if you haven't already).
Star Strider
Star Strider 2014 年 7 月 17 日
Thank you both!

サインインしてコメントする。


Shafiullah
Shafiullah 2015 年 5 月 13 日
please, help me I am implementing contours on mammogram image, Although I am getting right segmentation but i want the contour to be filled inside with some color.
[c h] = contour(u ,[0 0],'linecolor','r'); is simple contour with red colored line, now i want same contour but filled inside with redcolor.
i have tried contourf(u ,[0 0],'faceColor','r'); but it causes my whole image darker and invisible.
Suggest me please.

カテゴリ

Help Center および File ExchangeLighting, Transparency, and Shading についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by