Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Because Axe3D will calculate the <code>zorder</code> attribute for every 3d object by 3d projection. To disable this you can create a <code>FixZorderCollection</code> class and change the 3d line's <code>__class__</code> attribute. Here is a full example:</p> <pre><code>import sys, re, math import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import Axes3D from matplotlib.collections import LineCollection from matplotlib import cm from matplotlib.mlab import griddata import numpy as np x = [] y = [] z = [] for i in range(0,628,10) : for j in range(0,628,10) : x.append(i*0.01) y.append(j*0.01) z.append(math.sin(x[-1]*y[-1])*20) fig = plt.figure() ax = fig.gca(projection='3d') xi = np.linspace(min(x), max(x)) yi = np.linspace(min(y), max(y)) X, Y = np.meshgrid(xi, yi) Z = griddata(x, y, z, xi, yi) ax.autoscale(False) ax.view_init(elev=30, azim=-140) surf = ax.plot_surface(X, Y, Z, rstride=1, cstride=1, cmap=cm.cool, linewidth=0.1, antialiased=True, shade=True,alpha=0.8) cset = ax.contourf(X, Y, Z, zdir='z', offset=-100, cmap=cm.cool, cstride=1, linewidth=0.1, antialiased=True, shade=True) ax.set_xlim3d(0, math.pi*2) ax.set_ylim3d(0, math.pi*2) ax.set_zlim3d(-100, 20) xi = [0,6] yi = [3,3] l=zip(xi,yi) lines = LineCollection((l,l),zorder=1000,color='k',lw=3) ax.add_collection3d(lines,zs=-90) from mpl_toolkits.mplot3d.art3d import Line3DCollection class FixZorderCollection(Line3DCollection): _zorder = 1000 @property def zorder(self): return self._zorder @zorder.setter def zorder(self, value): pass ax.collections[-1].__class__ = FixZorderCollection plt.show() </code></pre> <p>output:</p> <p><img src="https://i.stack.imgur.com/M4FvK.png" alt="enter image description here"></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload