0

Running the code below (Python 3, matplotlib 2.0.2), I get the following output:

enter image description here

I would prefer, and expect, the graph to cover some of the paths below it. What is going wrong?

import numpy as np
from matplotlib import pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
paths = np.cumsum(np.random.normal(size=(10,10)),axis=0)
ax=plt.figure().gca(projection='3d')
ax.plot(np.tile(range(10),(10,1)).T,paths)
N=30
Y = np.linspace(-5,5, N) 
X = np.linspace(0,10,N)
XX, YY = np.meshgrid(X,Y)
ZZ = YY**2
ax.plot_surface(XX, YY, ZZ, alpha=1)
plt.show()
Bananach
  • 2,016
  • 26
  • 51
  • 1
    I guess this is the usual [My 3D plot doesn’t look right at certain viewing angles](https://matplotlib.org/mpl_toolkits/mplot3d/faq.html#my-3d-plot-doesn-t-look-right-at-certain-viewing-angles). – ImportanceOfBeingErnest Jan 16 '18 at 11:59
  • @ImportanceOfBeingErnest Not saying it isn't, but just to be clear: The output looks wrong from each and every angle, i.e. the paths are never covered at all, from any angle – Bananach Jan 16 '18 at 12:02
  • I guess they all intersect the surface at some point or another, so the problem will inevitably occur for *every* viewing angle. – ImportanceOfBeingErnest Jan 16 '18 at 12:05
  • Like in [this question](https://stackoverflow.com/questions/41699494/how-to-obscure-a-line-behind-a-surface-plot-in-matplotlib) the idea can be to calculate which points lie in front for a given viewing angle and restrict plotting of those points. – ImportanceOfBeingErnest Jan 16 '18 at 12:12
  • @ImportanceOfBeingErnest the problem also occurs if I shift the surface to lie strictly above the paths – Bananach Jan 16 '18 at 12:37
  • (in the graph that I posted, the paths never intersect, but touch the surface tangentially. anyway, the problem persists even when I lift the surface by ZZ=YY**2+10 – Bananach Jan 16 '18 at 12:39
  • Sorry, by intersect I mean intersect in the projected image, not intersect in true 3d space. – ImportanceOfBeingErnest Jan 16 '18 at 12:42

0 Answers0