I'm plotting 3d lines and points in matplotlib. On the output, there is always on top the last data plotted and not the "closer" data in the 3d projection. I would like to achieve a view that considers the perspective.
Here's a minimal code, In this case the red line is always on top of the blue line:
from mpl_toolkits.mplot3d import Axes3D
import numpy as np
import matplotlib.pyplot as plt
fig = plt.figure(figsize = [8, 14])
ax1 = fig.add_subplot(211, projection='3d')
ax2 = fig.add_subplot(212, projection='3d')
x = np.linspace(-1, 1, 100)
y = np.linspace(-1, 1, 100)
ax1.plot(x, y, 0, 'b', lw = 3)
ax1.plot(x, y, 1, 'r', lw = 3)
ax2.plot(x, y, 0, 'b', lw = 3)
ax2.plot(x, y, 1, 'r', lw = 3)
ax1.view_init(90, 0)
ax2.view_init(-90, 0)
plt.show()