@@ -384,6 +384,7 @@ def _get_image_inclusion_command():
384
384
385
385
class RendererPgf (RendererBase ):
386
386
387
+ @cbook ._delete_parameter ("3.3" , "dummy" )
387
388
def __init__ (self , figure , fh , dummy = False ):
388
389
"""
389
390
Creates a new PGF renderer that translates any drawing instruction
@@ -410,13 +411,6 @@ def __init__(self, figure, fh, dummy=False):
410
411
for m in RendererPgf .__dict__ :
411
412
if m .startswith ("draw_" ):
412
413
self .__dict__ [m ] = lambda * args , ** kwargs : None
413
- else :
414
- # if fh does not belong to a filename, deactivate draw_image
415
- if not hasattr (fh , 'name' ) or not os .path .exists (fh .name ):
416
- self .__dict__ ["draw_image" ] = \
417
- lambda * args , ** kwargs : cbook ._warn_external (
418
- "streamed pgf-code does not support raster graphics, "
419
- "consider using the pgf-to-pdf option" )
420
414
421
415
@cbook .deprecated ("3.2" )
422
416
def latexManager (self ):
@@ -643,6 +637,11 @@ def draw_image(self, gc, x, y, im, transform=None):
643
637
if w == 0 or h == 0 :
644
638
return
645
639
640
+ if not os .path .exists (getattr (self .fh , "name" , "" )):
641
+ cbook ._warn_external (
642
+ "streamed pgf-code does not support raster graphics, consider "
643
+ "using the pgf-to-pdf option." )
644
+
646
645
# save the images to png files
647
646
path = pathlib .Path (self .fh .name )
648
647
fname_img = "%s-img%d.png" % (path .stem , self .image_counter )
@@ -753,16 +752,11 @@ def points_to_pixels(self, points):
753
752
# docstring inherited
754
753
return points * mpl_pt_to_in * self .dpi
755
754
756
- def new_gc (self ):
757
- # docstring inherited
758
- return GraphicsContextPgf ()
759
-
760
755
756
+ @cbook .deprecated ("3.3" , alternative = "GraphicsContextBase" )
761
757
class GraphicsContextPgf (GraphicsContextBase ):
762
758
pass
763
759
764
- ########################################################################
765
-
766
760
767
761
class TmpDirCleaner :
768
762
remaining_tmpdirs = set ()
@@ -946,7 +940,7 @@ def print_png(self, fname_or_fh, *args, **kwargs):
946
940
self ._print_png_to_fh (file , * args , ** kwargs )
947
941
948
942
def get_renderer (self ):
949
- return RendererPgf (self .figure , None , dummy = True )
943
+ return RendererPgf (self .figure , None )
950
944
951
945
952
946
class FigureManagerPgf (FigureManagerBase ):
0 commit comments