필터 지우기
필터 지우기

Patch : intersecting polygon regions leaving holes at intersections.

조회 수: 5 (최근 30일)
Chirag Dudhat
Chirag Dudhat 2022년 10월 21일
댓글: Dyuman Joshi 2023년 9월 25일
I created a function which plots a line with variable thickness along the array. I am using Patch for that. The problem is those areas which I marked with red circles. How do I get rid of those holes (white areas) and make it same color as the line?
  댓글 수: 1
Benjamin Kraus
Benjamin Kraus 2022년 10월 21일
Without seeing you code, it isn't clear to me what would be causing those white patches.
Can you share your code?

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

답변 (1개)

Avni Agrawal
Avni Agrawal 2023년 9월 25일
편집: Avni Agrawal 2023년 9월 25일
Hi Chirag,
I understand that you are facing an issue with existing white area at the intersection while using patch function.
You can try implementing below code where there are no such holes, and the continuous line only exists.
x = [-7 0 7 -9 9 -7];
y = [-7 9 -7 4 4 -7];
hold on
for i=1:5
r = randi([1 10],1); % random line width generator
patch([x(i) x(i+1)], [y(i) y(i+1)],'b','EdgeColor','k','FaceColor','none','LineWidth', r);
end
hold off
Please refer to the patch documentation for further assistance.
  댓글 수: 1
Dyuman Joshi
Dyuman Joshi 2023년 9월 25일
patch() is not needed here -
x = [-7 0 7 -9 9 -7];
y = [-7 9 -7 4 4 -7];
figure
hold on
for i=1:numel(x)-1
r = randi(10); % random line width generator
plot([x(i) x(i+1)], [y(i) y(i+1)],'k-','LineWidth', r);
end
hold off

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

카테고리

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