@@ -2013,19 +2013,19 @@ def _switch_canvas_and_return_print_method(self, fmt, backend=None):
2013
2013
if not hasattr (canvas_class , f"print_{ fmt } " ):
2014
2014
raise ValueError (
2015
2015
f"The { backend !r} backend does not support { fmt } output" )
2016
+ canvas = canvas_class (self .figure )
2016
2017
elif hasattr (self , f"print_{ fmt } " ):
2017
2018
# Return the current canvas if it supports the requested format.
2018
2019
canvas = self
2019
- canvas_class = None # Skip call to switch_backends.
2020
2020
else :
2021
2021
# Return a default canvas for the requested format, if it exists.
2022
2022
canvas_class = get_registered_canvas_class (fmt )
2023
- if canvas_class :
2024
- canvas = self . switch_backends ( canvas_class )
2025
- if canvas is None :
2026
- raise ValueError (
2027
- "Format {!r} is not supported (supported formats: {})" . format (
2028
- fmt , ", " . join ( sorted ( self .get_supported_filetypes ()))))
2023
+ if canvas_class is None :
2024
+ raise ValueError (
2025
+ "Format {!r} is not supported (supported formats: {})" . format (
2026
+ fmt , ", " . join ( sorted ( self . get_supported_filetypes ()))))
2027
+ canvas = canvas_class ( self . figure )
2028
+ canvas . _is_saving = self ._is_saving
2029
2029
meth = getattr (canvas , f"print_{ fmt } " )
2030
2030
mod = (meth .func .__module__
2031
2031
if hasattr (meth , "func" ) # partialmethod, e.g. backend_wx.
@@ -2214,6 +2214,7 @@ def get_default_filename(self):
2214
2214
filename = basename + '.' + filetype
2215
2215
return filename
2216
2216
2217
+ @_api .deprecated ("3.8" )
2217
2218
def switch_backends (self , FigureCanvasClass ):
2218
2219
"""
2219
2220
Instantiate an instance of FigureCanvasClass
0 commit comments