Help with patch
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Hello, i need your help to understand how patch works. I have made a 2D plot in matlab and i would like to add some patches to it. I use the following commands
xpatch=[340.04 340.07;340.04 340.07]; % create x axis patch area
ypatch=[0 1600;0 1600]; % create y axis patch area
patch(xpatch,ypatch,'r');
my problem is that even if the patch object has been created in the plot brower of the figure window, it isn't visible in my figure. I would appreciate any help
Thank you
0 comentarios
Respuesta aceptada
Walter Roberson
el 29 de Feb. de 2012
Do not use 2D arrays for the patch coordinates: patch() wants vector lists of coordinates for each patch.
xpatch = [340.04 340.07 340.07 340.04 340.04];
ypatch = [0 0 1600 1600 0];
patch(xpatch,ypatch,'r')
The point order is important here, as are the seeming duplications.
4 comentarios
Walter Roberson
el 29 de Feb. de 2012
I prefer not to count upon patch() automatically closing the patch.
Más respuestas (1)
Kostas
el 29 de Feb. de 2012
1 comentario
Jonathan Sullivan
el 29 de Feb. de 2012
It works for me. Make sure you use the hold on command before trying to pot anything else on top.
Ver también
Categorías
Más información sobre Polygons en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!