MATLAB 2014b: patch() function not coloring the right region

4 ビュー (過去 30 日間)
San
San 2014 年 10 月 28 日
コメント済み: Image Analyst 2014 年 11 月 8 日
I was using patch() function to plot some data and it doesn't appear to place to color in the correct region. If you view the figure below (in the bottom panel). You will see that the boundary where I set for the color filled in or totally ignored. The error occurs at 7PM, 11PM, 5AM, 7AM etc. The red stars indicates the points for the patch and the red dotted line indicates the boundary where the patch tool suppose to place the color.
However if you zoom in for a patch (2nd figure), the color placement became corrected. I did not do anything to the patch except using the ZOOM tool in on the figure to zoom in.
If someone has a solution and would like to share. I would appreciate your help. Thank you.
-San-

回答 (3 件)

dami
dami 2014 年 11 月 5 日
I have the same problem with 2014b version. I don't understand how the zoom should solve the problem: also in your second figure not all the lines are patched properly.
I tried to replicate the problem as I described here.
It seems to be a bug of the new release, affecting patch and fill functions with concave polygons.
  1 件のコメント
San
San 2014 年 11 月 5 日
I totally agree with your thoughts. I am not sure when will Mathworks will release an update to fix this problem.

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


Image Analyst
Image Analyst 2014 年 11 月 6 日
Maybe try fill() or area() instead of patch()?
  1 件のコメント
Image Analyst
Image Analyst 2014 年 11 月 8 日
I suggest that whenever you have polygons where the edge intersects or crosses another edge, you plot it as two or more separate regions.

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


dami
dami 2014 年 11 月 6 日
Both fill() and patch() functions give wrong results and area() function is different because does not support concave polygons.
Is there a way to report to MathWorks this behavior as a bug?
  2 件のコメント
Image Analyst
Image Analyst 2014 年 11 月 6 日
Or you can give a small simple example here, to illustrate it.
Image Analyst
Image Analyst 2014 年 11 月 8 日
dami's "Answer" moved here since it's a reply to me rather than a solution to the original posting.
Here you can find an example, I'm stuck for days, I cannot even find a workaround.

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

カテゴリ

Help Center および File ExchangePolygons についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by