필터 지우기
필터 지우기

Rendering issues in Matlab R2014b version when using patch

조회 수: 1 (최근 30일)
Giorgos Papakonstantinou
Giorgos Papakonstantinou 2014년 12월 5일
편집: Giorgos Papakonstantinou 2014년 12월 6일
I am using patch to shade an area in a graph. The code that I am using is simple:
lm = 0;
s = 1:1000;
d = [ones(1, 100) zeros(1, 800) -1*ones(1, 100)];
xdata = [s(1) s s(end)];
ydata = [lm d lm];
patch(xdata, ydata, ones(size(xdata)));
In the attachment, the left figure is produced from R2014b version and the right from version R2012b.
Is there a workaround to deal with this problem? Have you also noticed it?
Thank you very much in advance.

답변 (3개)

Titus Edelhofer
Titus Edelhofer 2014년 12월 5일
Hi,
I think you need to add the line at the zero:
lm = 0;
s = 1:1000;
d = [ones(1, 100) zeros(1, 800) -1*ones(1, 100)];
xdata = [s(100) s(1) s s(end) s(end-99)];
ydata = [lm lm d lm lm];
patch(xdata, ydata, ones(size(xdata)));
I'm not sure why it works fine in 12b ...
Titus
  댓글 수: 4
Giorgos Papakonstantinou
Giorgos Papakonstantinou 2014년 12월 5일
Is it possible to have an answer from Mathworks?
Mike Garrity
Mike Garrity 2014년 12월 5일
편집: Mike Garrity 2014년 12월 5일
It sounds like another instance of this bug, but you should send it to support to make sure they're tracking it.
I think that one had to do with multiple edges which were colinear, but didn't have coincident vertices.

댓글을 달려면 로그인하십시오.


Giorgos Papakonstantinou
Giorgos Papakonstantinou 2014년 12월 5일
Thank you Mike for you input. The simplest workaround that can overcome this problem is setting the value lm very low. i.e.
lm = 1e-5; % practically zero
s = 1:1000;
d = [ones(1, 100) zeros(1, 800) -1*ones(1, 100)];
xdata = [s(1) s s(end)];
ydata = [lm d lm];
patch(xdata, ydata, ones(size(xdata)));
This can fix it for the moment, as you can see below:

matt dash
matt dash 2014년 12월 5일
I suppose this qualifies as a bug, but it seems like a bad coding practice. If you know you want the patch to produce a series of bars, like a histogram, a better option is (at least to me) to plot each bar as a face of the patch by supplying all 4 vertices. I don't think the overhead of making each bar a separate face of the patch will be noticeable, even for very complex plots.
  댓글 수: 1
Giorgos Papakonstantinou
Giorgos Papakonstantinou 2014년 12월 6일
편집: Giorgos Papakonstantinou 2014년 12월 6일
Yes I agree with you. However here, I am not using patch to produce some bars. I use it to patch an area. I just gave a simple example which appears like patched bars, to illustrate the problem.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Polygons에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by