필터 지우기
필터 지우기

How to draw a rectangle over a patch?

조회 수: 18 (최근 30일)
Nathaniel Levi Blank
Nathaniel Levi Blank 2021년 4월 21일
편집: giannit 2021년 5월 7일
Hello, I need to draw a rectangle with curved edges over a background that I created using patch(). For the rectangle I am using the function rectangel() because it has a curvature property. I know that other functions have a property like 'layer' that lets me place things on top of others, but rectangle() doesn't have this property. I am open to alternative methods of creating the rounded rectangle or the background so that I can get the final result.
Thanks in advance!

채택된 답변

Jan
Jan 2021년 4월 21일
편집: Jan 2021년 4월 21일
You can draw into different AXES objects, while the top one is invisible:
FigH = figure;
Axes1H = axes(FigH, 'XLim', [0, 100], 'YLim', [0, 100]);
Axes2H = axes(FigH, 'XLim', [0, 100], 'YLim', [0, 100], ...
'Visible', 'off'); % On top of Axes1H
patch(Axes1H, [20, 20, 80, 80], [10, 90, 90, 10], [1,0,0])
rectangle(Axes2H, 'Position', [10, 40, 80, 30], 'Curvature', 0.5)
  댓글 수: 2
Nathaniel Levi Blank
Nathaniel Levi Blank 2021년 4월 22일
Great, thanks!
giannit
giannit 2021년 5월 7일
편집: giannit 2021년 5월 7일
You can decide who stays at top simply using the Z-axis coordinates of patch.
This will plot the same as Jan
Z = 0*ones(1,4);
patch([20, 20, 80, 80], [10, 90, 90, 10], Z, [1,0,0])
rectangle('Position', [10, 40, 80, 30], 'Curvature', 0.5)
while with Z = 1*ones(1,4) it will plot the patch over the rectangle.

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

추가 답변 (0개)

카테고리

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