Why do line and patch objects overlap or intersect incorrectly in MATLAB figures?
14 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
MathWorks Support Team
el 27 de Jun. de 2009
Editada: MathWorks Support Team
el 10 de Nov. de 2025
Why do line and patch objects overlap or intersect incorrectly in MATLAB figures?
I created a three-dimensional plot that contains patch and line objects, using the folowing code:
ax = newplot;
vert = [ -.5, -.5, 0;
.5, -.5, 0;
.5, .5, 0;
-.5, .5, 0;
0, 0, -1;
0, 0, 1];
face = [1 2 5;
2 3 5;
3 4 5;
4 1 5;
1 6 2;
2 6 3;
3 6 4;
4 6 1];
patch('Faces',face,...
'Vertices',vert,...
'FaceColor','red',...
'EdgeColor','black');
view(ax,3)
hold on
plot3([0 0],[-.5 .5],[-1 1])
The line should intersect the faces of the patch. However, the line appears to intersect the edge of the patch. Rotating the axes may cause the line to disappear from sight, or appear completely inside the patch.
Respuesta aceptada
MathWorks Support Team
el 10 de Nov. de 2025
Editada: MathWorks Support Team
el 10 de Nov. de 2025
This effect is the result of using the painters renderer, which does not display overlapping or intersection correctly. Changing the figure's Renderer property to specify the OpenGL or zbuffer renderer will display the objects properly:
set(gcf,'Renderer','opengl')
or
set(gcf,'Renderer','zbuffer')
for more information on specifying the renderer in MATLAB, see the doc page on "Figure Properties"
0 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Lighting, Transparency, and Shading en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!