Matplotlib does not display intersection of 3D planes correctly

I want to build two planes and find their intersection line, but I get this result when it is impossible to determine where they intersect, because one plane overlaps the other.

The 3D projection should hide the invisible part of the plane, how can I achieve this result using matplotlib ?

planes

You can clearly see that they must intersect on the plains.

plane intersect

Here is the code I used to get this result

import numpy as np import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import Axes3D values = range(-10, 11) def plotPlane(plot, normal, d, values, colorName): # x, y, z x, y = np.meshgrid(values, values) z = (-normal[0] * x - normal[1] * y - d) * 1. / normal[2] # draw plot plot.plot_surface(x, y, z, color=colorName) image = plt.figure().gca(projection='3d') plotPlane(image, [3, 2, -4], 1, values, "red") plotPlane(image, [5, -1, 2], 4, values, "gray") plt.show() 
+2
source share
1 answer

See How to draw intersecting planes? for a long explanation + possible work.

The short answer is that matplotlib 3D support is the smart use of predictions to create a 2D view of a 3D object that is then displayed on the canvas. Due to the fact that matplotlib provides (an artist at the same time), one artist is completely or completely below the other. If you need real support for 3D support in mayavi .

+4
source

Source: https://habr.com/ru/post/981752/


All Articles