diff --git a/CHANGELOG b/CHANGELOG index 352c176fa11b..5e0fa014ac13 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,6 @@ +2012-12-31 Added set_3d_data to Line3D to update the data of an existing + Line3d object. - TAC + 2012-12-05 Added MatplotlibDeprecationWarning class for signaling deprecation. Matplotlib developers can use this class as follows: diff --git a/lib/mpl_toolkits/mplot3d/art3d.py b/lib/mpl_toolkits/mplot3d/art3d.py index 53ba0fe2e559..804506cd2c72 100644 --- a/lib/mpl_toolkits/mplot3d/art3d.py +++ b/lib/mpl_toolkits/mplot3d/art3d.py @@ -94,14 +94,19 @@ class Line3D(lines.Line2D): 3D line object. ''' - def __init__(self, xs, ys, zs, *args, **kwargs): + def __init__(self, xs, ys, zs, zdir='z', *args, **kwargs): ''' + *zdir* sets with axes to treat as 'z' + Keyword arguments are passed onto :func:`~matplotlib.lines.Line2D`. ''' lines.Line2D.__init__(self, [], [], *args, **kwargs) - self._verts3d = xs, ys, zs + self.set_3d_data(xs, ys, zs, zdir) def set_3d_properties(self, zs=0, zdir='z'): + # this is broken, because if the line has + # ever been drawn, these are the projected (x,y) + # see draw() xs = self.get_xdata() ys = self.get_ydata() @@ -112,6 +117,21 @@ def set_3d_properties(self, zs=0, zdir='z'): pass self._verts3d = juggle_axes(xs, ys, zs, zdir) + def set_3d_data(self, xs=None, ys=None, zs=None, zdir='z'): + x_old, y_old, z_old = self._verts3d + if xs is None: + xs = x_old + if ys is None: + ys = y_old + if zs is None: + zs = z_old + try: + zs = float(zs) + zs = [zs for x in xs] + except: + pass + self._verts3d = juggle_axes(xs, ys, zs, zdir) + def draw(self, renderer): xs3d, ys3d, zs3d = self._verts3d xs, ys, zs = proj3d.proj_transform(xs3d, ys3d, zs3d, renderer.M)