I found that

def set_sort_zpos(self,val):
      '''Set the position to use for z-sorting.'''
      self._sort_zpos = val

was missing from

class Line3DCollection(LineCollection) (in matplotlib 1.0.1):

Now,  with the above method added, add_collection3d works as it should with 
line 
segments, and the following will work as expected :-)

'''
  Purpose: Waterfall plot using LineCollection
  Author: V.P.S. (2011-03-26)
'''
from mpl_toolkits.mplot3d import Axes3D
from matplotlib.collections import LineCollection
from matplotlib.colors import colorConverter
import matplotlib.pyplot as plt
import numpy as np

np.random.seed(40040157) # Used to allow repeatable experiments (plots)

fig = plt.figure()
ax = fig.gca(projection='3d')

cc = [colorConverter.to_rgba(c,alpha=0.6) for c in 
('r','g','b','c','y','m','k')]
ncc = len(cc)

nxs = 5      # Num of points to connect (nxs-1 line segments)
# Generate X values
xs = np.arange(1, nxs+1, 1)

# Create array of Y values (to be updated)
ys = np.zeros(nxs)

# Create list of Z values
nzs = 4      # Num of Z-planes
zs = [zs+1 for zs in range(nzs)]

# Create list of colors (cyclic) for lines
colorlist = [cc[j%ncc] for j in range(nzs)]

segs = []
# Generate line segments in each Z-plane
for j in zs:
     ys = np.random.rand(nxs)
     segs.append(zip(xs, ys))

curves = LineCollection(segs, colors = colorlist)

ax.add_collection3d(curves, zs=zs, zdir='y')

ax.set_xlabel('X')         # points to right     -- X
ax.set_xlim3d(0, nxs+1)
ax.set_ylabel('Y')         # points into screen  -- Y
ax.set_ylim3d(0, nzs+1)
ax.set_zlabel('Z')         # points up           -- Z
ax.set_zlim3d(0, 1)

plt.show()

Have a Good Day
--V


------------------------------------------------------------------------------
Create and publish websites with WebMatrix
Use the most popular FREE web apps or write code yourself; 
WebMatrix provides all the features you need to develop and publish 
your website. http://p.sf.net/sfu/ms-webmatrix-sf
_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel

Reply via email to