Permalink
Browse files

added a set_3d_data function to Line3D which works in the same

spirit as set_xdata and set_ydata for Line2D, but requires _all_
of the data to be set in one go (to not have to write the caching
layer of Line2D again yet).
  • Loading branch information...
1 parent 1787a1a commit ecbc43e693d707764b34dfef17dca21522713866 Thomas A Caswell committed Dec 31, 2012
Showing with 12 additions and 1 deletion.
  1. +12 −1 lib/mpl_toolkits/mplot3d/art3d.py
@@ -99,9 +99,12 @@ def __init__(self, xs, ys, zs, *args, **kwargs):
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)
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 +115,14 @@ def set_3d_properties(self, zs=0, zdir='z'):
pass
self._verts3d = juggle_axes(xs, ys, zs, zdir)
+ def set_3d_data(self, xs, ys, zs, zdir='z'):
+ 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)

0 comments on commit ecbc43e

Please sign in to comment.