@@ -97,7 +97,7 @@ def __init__(self, ax,
97
97
98
98
self ._imcache = None
99
99
100
- # this is an expetimental attribute, if True, unsampled image
100
+ # this is an experimental attribute, if True, unsampled image
101
101
# will be drawn using the affine transform that are
102
102
# appropriately skewed so that the given postition
103
103
# corresponds to the actual position in the coordinate. -JJL
@@ -797,6 +797,9 @@ def __init__(self, ax,
797
797
cm .ScalarMappable .__init__ (self , norm , cmap )
798
798
self .axes = ax
799
799
self ._rgbacache = None
800
+ # There is little point in caching the image itself because
801
+ # it needs to be remade if the bbox or viewlim change,
802
+ # so caching does help with zoom/pan/resize.
800
803
self .update (kwargs )
801
804
self .set_data (x , y , A )
802
805
@@ -811,7 +814,7 @@ def make_image(self, magnification=1.0):
811
814
height = (round (t ) + 0.5 ) - (round (b ) - 0.5 )
812
815
width = width * magnification
813
816
height = height * magnification
814
- if self .check_update ( 'array' ) :
817
+ if self ._rgbacache is None :
815
818
A = self .to_rgba (self ._A , alpha = self ._alpha , bytes = True )
816
819
self ._rgbacache = A
817
820
if self ._A .ndim == 2 :
@@ -827,9 +830,14 @@ def make_image(self, magnification=1.0):
827
830
im .is_grayscale = self .is_grayscale
828
831
return im
829
832
833
+ def changed (self ):
834
+ self ._rgbacache = None
835
+ cm .ScalarMappable .changed (self )
836
+
830
837
@allow_rasterization
831
838
def draw (self , renderer , * args , ** kwargs ):
832
- if not self .get_visible (): return
839
+ if not self .get_visible ():
840
+ return
833
841
im = self .make_image (renderer .get_image_magnification ())
834
842
gc = renderer .new_gc ()
835
843
gc .set_clip_rectangle (self .axes .bbox .frozen ())
@@ -871,7 +879,7 @@ def set_data(self, x, y, A):
871
879
self ._A = A
872
880
self ._Ax = x
873
881
self ._Ay = y
874
- self .update_dict [ 'array' ] = True
882
+ self ._rgbacache = None
875
883
876
884
def set_array (self , * args ):
877
885
raise NotImplementedError ('Method not supported' )
0 commit comments