A 3D object appears in front of another object, even though it is physically behind it. #9499
A 3D object appears in front of another object, even though it is physically behind it.
Code for reproduction
import matplotlib as mpl from mpl_toolkits.mplot3d import Axes3D from matplotlib.patches import Circle, Rectangle import matplotlib.path as mpath import matplotlib.patches as mpatches import numpy as np import mpl_toolkits.mplot3d.art3d as art3d import matplotlib.pyplot as plt mpl.rcParams['legend.fontsize'] = 10 fig = plt.figure() ax = fig.gca(projection='3d') ax.set_xlim(-16, 16) ax.set_ylim(-16, 16) ax.set_zlim(-16, 16) for depth in [0.]: theta = np.linspace(-5 * np.pi, 5 * np.pi, 1000) x = depth * np.ones(theta.shape) y = theta z = 4 * np.cos(0.2 * theta) * np.sin(0.4 * 8 * theta) points = np.array([y, z]).T patch = mpatches.PathPatch(mpath.Path(points)) ax.add_patch(patch) art3d.pathpatch_2d_to_3d(patch, z=depth, zdir='x') for depth in range(6 ,7): ret = Rectangle((0-5, 0-5), 5 * 2, 5 * 2, facecolor=(depth /10, depth/10, depth/10), edgecolor=(0.,0.,0.), alpha=1.) ax.add_patch(ret) art3d.pathpatch_2d_to_3d(ret, z=depth, zdir='x') plt.show()
This is a well known issue, acknowlegded and documented at http://matplotlib.org/mpl_toolkits/mplot3d/faq.html#my-3d-plot-doesn-t-look-right-at-certain-viewing-angles, and the general agreement is that it would be quite difficult to solve.