#NEWLINE# def annotation_heatmap( self , ax , X , annotation , extent = None , label = 'Gradient' , imshow_kwargs = None , **annotation_kwargs ) : #NEWLINE# #INDENT# imshow_kwargs . setdefault ( 'label' , label ) #NEWLINE# imshow_kwargs . setdefault ( 'showscale' , True ) #NEWLINE# imshow = self . imshow ( ax , X , extent , ** imshow_kwargs ) #NEWLINE# X = ( X - X . min ( ) ) #NEWLINE# X /= ( X . max ( ) / 2.0 ) #NEWLINE# X -= 1 #NEWLINE# x = np . linspace ( extent [ 0 ] , extent [ 1 ] , X . shape [ 0 ] ) #NEWLINE# y = np . linspace ( extent [ 2 ] , extent [ 3 ] , X . shape [ 1 ] ) #NEWLINE# annotations = Annotations ( ) #NEWLINE# for ( n , row ) in enumerate ( annotation ) : #NEWLINE# #INDENT# for ( m , val ) in enumerate ( row ) : #NEWLINE# #INDENT# var = X [ n ] [ m ] #NEWLINE# annotations . append ( Annotation ( text = str ( val ) , x = x [ m ] , y = y [ n ] , xref = 'x1' , yref = 'y1' , font = dict ( color = ( 'white' if ( np . abs ( var ) > 0.8 ) else 'black' ) , size = 10 ) , opacity = 0.5 , showarrow = False ) ) #NEWLINE# #UNINDENT# #UNINDENT# return ( imshow , annotations )