@@ -248,7 +248,8 @@ def __init__(self, xdata, ydata,
248248
249249 self ._xorig = np .asarray ([])
250250 self ._yorig = np .asarray ([])
251- self ._invalid = True
251+ self ._invalidx = True
252+ self ._invalidy = True
252253 self .set_data (xdata , ydata )
253254
254255 def contains (self , mouseevent ):
@@ -272,7 +273,7 @@ def contains(self, mouseevent):
272273 raise ValueError ,"pick radius should be a distance"
273274
274275 # Make sure we have data to plot
275- if self ._invalid :
276+ if self ._invalidy or self . _invalidx :
276277 self .recache ()
277278 if len (self ._xy )== 0 : return False ,{}
278279
@@ -403,36 +404,28 @@ def set_data(self, *args):
403404 else :
404405 x , y = args
405406
406- not_masked = 0
407- if not ma .isMaskedArray (x ):
408- x = np .asarray (x )
409- not_masked += 1
410- if not ma .isMaskedArray (y ):
411- y = np .asarray (y )
412- not_masked += 1
413-
414- if (not_masked < 2 or
415- (x is not self ._xorig and
416- (x .shape != self ._xorig .shape or np .any (x != self ._xorig ))) or
417- (y is not self ._yorig and
418- (y .shape != self ._yorig .shape or np .any (y != self ._yorig )))):
419- self ._xorig = x
420- self ._yorig = y
421- self ._invalid = True
407+ self .set_xdata (x )
408+ self .set_ydata (y )
422409
423410 def recache (self ):
424- #if self.axes is None: print 'recache no axes'
425- #else: print 'recache units', self.axes.xaxis.units, self.axes.yaxis.units
426- if ma .isMaskedArray (self ._xorig ) or ma .isMaskedArray (self ._yorig ):
427- x = ma .asarray (self .convert_xunits (self ._xorig ), float )
428- y = ma .asarray (self .convert_yunits (self ._yorig ), float )
429- x = ma .ravel (x )
430- y = ma .ravel (y )
411+ if self ._invalidx :
412+ xconv = self .convert_xunits (self ._xorig )
413+ if ma .isMaskedArray (self ._xorig ):
414+ x = ma .asarray (xconv , float )
415+ else :
416+ x = np .asarray (xconv , float )
417+ x = x .ravel ()
418+ else :
419+ x = self ._x
420+ if self ._invalidy :
421+ yconv = self .convert_yunits (self ._yorig )
422+ if ma .isMaskedArray (self ._yorig ):
423+ y = ma .asarray (yconv , float )
424+ else :
425+ y = np .asarray (yconv , float )
426+ y = y .ravel ()
431427 else :
432- x = np .asarray (self .convert_xunits (self ._xorig ), float )
433- y = np .asarray (self .convert_yunits (self ._yorig ), float )
434- x = np .ravel (x )
435- y = np .ravel (y )
428+ y = self ._y
436429
437430 if len (x )== 1 and len (y )> 1 :
438431 x = x * np .ones (y .shape , float )
@@ -455,16 +448,16 @@ def recache(self):
455448 self ._subslice = False
456449 if (self .axes and len (x ) > 100 and self ._is_sorted (x ) and
457450 self .axes .name == 'rectilinear' and
458- self .axes .get_xscale () == 'linear' and
459- self .axes .get_yscale () == 'linear' ):
451+ self .axes .get_xscale () == 'linear' ):
460452 self ._subslice = True
461453 if hasattr (self , '_path' ):
462454 interpolation_steps = self ._path ._interpolation_steps
463455 else :
464456 interpolation_steps = 1
465457 self ._path = Path (self ._xy , None , interpolation_steps )
466458 self ._transformed_path = None
467- self ._invalid = False
459+ self ._invalidx = False
460+ self ._invalidy = False
468461
469462 def _transform_path (self , subslice = None ):
470463 # Masked arrays are now handled by the Path class itself
@@ -482,7 +475,8 @@ def set_transform(self, t):
482475 ACCEPTS: a :class:`matplotlib.transforms.Transform` instance
483476 """
484477 Artist .set_transform (self , t )
485- self ._invalid = True
478+ self ._invalidx = True
479+ self ._invalidy = True
486480
487481 def _is_sorted (self , x ):
488482 "return true if x is sorted"
@@ -491,7 +485,7 @@ def _is_sorted(self, x):
491485
492486 @allow_rasterization
493487 def draw (self , renderer ):
494- if self ._invalid :
488+ if self ._invalidy or self . _invalidx :
495489 self .recache ()
496490 if self ._subslice and self .axes :
497491 # Need to handle monotonically decreasing case also...
@@ -619,7 +613,7 @@ def get_xdata(self, orig=True):
619613 """
620614 if orig :
621615 return self ._xorig
622- if self ._invalid :
616+ if self ._invalidx :
623617 self .recache ()
624618 return self ._x
625619
@@ -632,7 +626,7 @@ def get_ydata(self, orig=True):
632626 """
633627 if orig :
634628 return self ._yorig
635- if self ._invalid :
629+ if self ._invalidy :
636630 self .recache ()
637631 return self ._y
638632
@@ -641,15 +635,15 @@ def get_path(self):
641635 Return the :class:`~matplotlib.path.Path` object associated
642636 with this line.
643637 """
644- if self ._invalid :
638+ if self ._invalidy or self . _invalidx :
645639 self .recache ()
646640 return self ._path
647641
648642 def get_xydata (self ):
649643 """
650644 Return the *xy* data as a Nx2 numpy array.
651645 """
652- if self ._invalid :
646+ if self ._invalidy or self . invalidx :
653647 self .recache ()
654648 return self ._xy
655649
@@ -840,15 +834,17 @@ def set_xdata(self, x):
840834
841835 ACCEPTS: 1D array
842836 """
843- self .set_data (x , self ._yorig )
837+ self ._xorig = x
838+ self ._invalidx = True
844839
845840 def set_ydata (self , y ):
846841 """
847842 Set the data np.array for y
848843
849844 ACCEPTS: 1D array
850845 """
851- self .set_data (self ._xorig , y )
846+ self ._yorig = y
847+ self ._invalidy = True
852848
853849 def set_dashes (self , seq ):
854850 """
0 commit comments