Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Update x,y.z values for an existing Line3D object #1629

Closed
wants to merge 5 commits into
from
View
@@ -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:
@@ -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)