@@ -53,7 +53,6 @@ class TexManager:
5353
5454 # Caches.
5555 texcache = os .path .join (mpl .get_cachedir (), 'tex.cache' )
56- rgba_arrayd = {}
5756 grey_arrayd = {}
5857
5958 font_family = 'serif'
@@ -85,6 +84,11 @@ class TexManager:
8584 def cachedir (self ):
8685 return mpl .get_cachedir ()
8786
87+ @cbook .deprecated ("3.3" )
88+ @property
89+ def rgba_arrayd (self ):
90+ return {}
91+
8892 @functools .lru_cache () # Always return the same instance.
8993 def __new__ (cls ):
9094 Path (cls .texcache ).mkdir (parents = True , exist_ok = True )
@@ -369,30 +373,25 @@ def make_png(self, tex, fontsize, dpi):
369373
370374 def get_grey (self , tex , fontsize = None , dpi = None ):
371375 """Return the alpha channel."""
376+ if not fontsize :
377+ fontsize = rcParams ['font.size' ]
378+ if not dpi :
379+ dpi = rcParams ['savefig.dpi' ]
372380 key = tex , self .get_font_config (), fontsize , dpi
373381 alpha = self .grey_arrayd .get (key )
374382 if alpha is None :
375383 pngfile = self .make_png (tex , fontsize , dpi )
376- X = mpl .image .imread (os .path .join (self .texcache , pngfile ))
377- self .grey_arrayd [key ] = alpha = X [:, :, - 1 ]
384+ rgba = mpl .image .imread (os .path .join (self .texcache , pngfile ))
385+ self .grey_arrayd [key ] = alpha = rgba [:, :, - 1 ]
378386 return alpha
379387
380388 def get_rgba (self , tex , fontsize = None , dpi = None , rgb = (0 , 0 , 0 )):
381389 """Return latex's rendering of the tex string as an rgba array."""
382- if not fontsize :
383- fontsize = rcParams ['font.size' ]
384- if not dpi :
385- dpi = rcParams ['savefig.dpi' ]
386- r , g , b = rgb
387- key = tex , self .get_font_config (), fontsize , dpi , tuple (rgb )
388- Z = self .rgba_arrayd .get (key )
389-
390- if Z is None :
391- alpha = self .get_grey (tex , fontsize , dpi )
392- Z = np .dstack ([r , g , b , alpha ])
393- self .rgba_arrayd [key ] = Z
394-
395- return Z
390+ alpha = self .get_grey (tex , fontsize , dpi )
391+ rgba = np .empty ((* alpha .shape , 4 ))
392+ rgba [..., :3 ] = mpl .colors .to_rgb (rgb )
393+ rgba [..., - 1 ] = alpha
394+ return rgba
396395
397396 def get_text_width_height_descent (self , tex , fontsize , renderer = None ):
398397 """Return width, height and descent of the text."""
0 commit comments