Line through polygon using patch
조회 수: 5 (최근 30일)
이전 댓글 표시
I am trying to use a work-around in order to make a transparent line. It works, however, I keep getting a line through the middle of my graphic. Can somebody please tell me why?
x = linspace(0,10);
y1 = 4 + sin(x).*exp(0.1*x);
y2 = 4 + cos(x).*exp(0.1*x);
patch(x, y2, 'w', 'EdgeColor', 'r', 'EdgeAlpha', 1, 'FaceColor', 'r', 'FaceAlpha', 1)
hold on
patch(x, y1, 'w', 'Edgecolor', 'b', 'EdgeAlpha', 0.3, 'FaceColor', 'w', 'FaceAlpha', 0)
hold off
댓글 수: 2
Star Strider
2016년 2월 22일
Please go into a bit of detail about what you want to do, and what line you want to eliminate.
채택된 답변
Mike Garrity
2016년 2월 22일
Patch wants to draw closed polygons. If you don't want the line from the end of the second patch back to the beginning, then the easiest way is to add a nan like this:
x = linspace(0,10);
y1 = 4 + sin(x).*exp(0.1*x);
y2 = 4 + cos(x).*exp(0.1*x);
patch(x, y2, 'w', 'EdgeColor', 'r', 'EdgeAlpha', 1, 'FaceColor', 'r', 'FaceAlpha', 1)
hold on
patch([x nan], [y1 nan], 'w', 'Edgecolor', 'b', 'EdgeAlpha', 0.3, 'FaceColor', 'w', 'FaceAlpha', 0)
hold off
댓글 수: 2
Angelica Laurita
2021년 6월 11일
Hello! I'm having the same problem, but I cannot solve it using nan since I obtain the error "Error using horzcat. Dimensions of arrays being concatenated are not consistent."
Any ideas on how I could do?
Than you!
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Polygons에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!