@@ -386,6 +386,7 @@ def _get_image_inclusion_command():
386386
387387class RendererPgf (RendererBase ):
388388
389+ @cbook ._delete_parameter ("3.3" , "dummy" )
389390 def __init__ (self , figure , fh , dummy = False ):
390391 """
391392 Creates a new PGF renderer that translates any drawing instruction
@@ -412,13 +413,6 @@ def __init__(self, figure, fh, dummy=False):
412413 for m in RendererPgf .__dict__ :
413414 if m .startswith ("draw_" ):
414415 self .__dict__ [m ] = lambda * args , ** kwargs : None
415- else :
416- # if fh does not belong to a filename, deactivate draw_image
417- if not hasattr (fh , 'name' ) or not os .path .exists (fh .name ):
418- self .__dict__ ["draw_image" ] = \
419- lambda * args , ** kwargs : cbook ._warn_external (
420- "streamed pgf-code does not support raster graphics, "
421- "consider using the pgf-to-pdf option" )
422416
423417 @cbook .deprecated ("3.2" )
424418 @property
@@ -646,6 +640,11 @@ def draw_image(self, gc, x, y, im, transform=None):
646640 if w == 0 or h == 0 :
647641 return
648642
643+ if not os .path .exists (getattr (self .fh , "name" , "" )):
644+ cbook ._warn_external (
645+ "streamed pgf-code does not support raster graphics, consider "
646+ "using the pgf-to-pdf option." )
647+
649648 # save the images to png files
650649 path = pathlib .Path (self .fh .name )
651650 fname_img = "%s-img%d.png" % (path .stem , self .image_counter )
@@ -756,16 +755,11 @@ def points_to_pixels(self, points):
756755 # docstring inherited
757756 return points * mpl_pt_to_in * self .dpi
758757
759- def new_gc (self ):
760- # docstring inherited
761- return GraphicsContextPgf ()
762-
763758
759+ @cbook .deprecated ("3.3" , alternative = "GraphicsContextBase" )
764760class GraphicsContextPgf (GraphicsContextBase ):
765761 pass
766762
767- ########################################################################
768-
769763
770764class TmpDirCleaner :
771765 remaining_tmpdirs = set ()
@@ -949,7 +943,7 @@ def print_png(self, fname_or_fh, *args, **kwargs):
949943 self ._print_png_to_fh (file , * args , ** kwargs )
950944
951945 def get_renderer (self ):
952- return RendererPgf (self .figure , None , dummy = True )
946+ return RendererPgf (self .figure , None )
953947
954948
955949class FigureManagerPgf (FigureManagerBase ):
0 commit comments