 # Missing method!

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.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

Virgil,

Thanks for noticing this. There are several missing methods in the various 3D collections and artists, and I am sure we haven’t found them all yet. I am currently too busy to investigate why this particular one was missing, but in about a month I will have some time to do so.

Ben Root

···

On Sat, Mar 26, 2011 at 10:16 AM, Virgil Stokes <vs@…950…> wrote:

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.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

Virgil,

I have verified your observations, and the patch was added to the master branch. I tried to attribute the patch to you, but I don’t think I did it correctly.

Thanks,

Ben Root

···

On Thu, Mar 31, 2011 at 11:39 AM, Benjamin Root <ben.root@…553…> wrote:

On Sat, Mar 26, 2011 at 10:16 AM, Virgil Stokes <vs@…950…> wrote:

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.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

Virgil,

Thanks for noticing this. There are several missing methods in the various 3D collections and artists, and I am sure we haven’t found them all yet. I am currently too busy to investigate why this particular one was missing, but in about a month I will have some time to do so.

Ben Root