Borrar filtros
Borrar filtros

How to draw a rectangle over a patch?

19 visualizaciones (últimos 30 días)
Nathaniel Levi Blank
Nathaniel Levi Blank el 21 de Abr. de 2021
Editada: giannit el 7 de Mayo de 2021
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!

Respuesta aceptada

Jan
Jan el 21 de Abr. de 2021
Editada: Jan el 21 de Abr. de 2021
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 comentarios
Nathaniel Levi Blank
Nathaniel Levi Blank el 22 de Abr. de 2021
Great, thanks!
giannit
giannit el 7 de Mayo de 2021
Editada: giannit el 7 de Mayo de 2021
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.

Iniciar sesión para comentar.

Más respuestas (0)

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by