File tree Expand file tree Collapse file tree 1 file changed +4
-6
lines changed
Expand file tree Collapse file tree 1 file changed +4
-6
lines changed Original file line number Diff line number Diff line change @@ -560,13 +560,11 @@ def print_to_buffer(self):
560560
561561 @_api .delete_parameter ("3.5" , "args" )
562562 def print_jpg (self , filename_or_obj , * args , pil_kwargs = None ):
563- # Remove transparency by alpha-blending on an assumed white background.
564- r , g , b , a = mcolors . to_rgba ( self . figure . get_facecolor ())
565- try :
566- self . figure . set_facecolor ( a * np . array ([ r , g , b ]) + 1 - a )
563+ # savefig() has already applied savefig.facecolor; we now set it to
564+ # white to make imsave() blend semi-transparent figures against an
565+ # assumed white background.
566+ with mpl . rc_context ({ "savefig.facecolor" : "white" }):
567567 self ._print_pil (filename_or_obj , "jpeg" , pil_kwargs )
568- finally :
569- self .figure .set_facecolor ((r , g , b , a ))
570568
571569 print_jpeg = print_jpg
572570
You can’t perform that action at this time.
0 commit comments