diff --git a/doc/api/next_api_changes/2018-10-24-JMK.rst b/doc/api/next_api_changes/2018-10-24-JMK.rst new file mode 100644 index 000000000000..febb566ee947 --- /dev/null +++ b/doc/api/next_api_changes/2018-10-24-JMK.rst @@ -0,0 +1,7 @@ +Matplotlib.use now has an ImportError for interactive backend +------------------------------------------------------------- + +Switching backends via `matplotlib.use` is now allowed by default, +regardless of whether `matplotlib.pyplot` has been imported. If the user +tries to switch from an already-started interactive backend to a different +interactive backend, an ImportError will be raised. diff --git a/lib/matplotlib/__init__.py b/lib/matplotlib/__init__.py index 168e87ca2837..a2b16911867f 100644 --- a/lib/matplotlib/__init__.py +++ b/lib/matplotlib/__init__.py @@ -1292,7 +1292,7 @@ def __exit__(self, exc_type, exc_value, exc_tb): self.__fallback() -def use(arg, warn=True, force=False): +def use(arg, warn=False, force=True): """ Set the matplotlib backend to one of the known backends. @@ -1318,11 +1318,12 @@ def use(arg, warn=True, force=False): If True, warn if this is called after pyplot has been imported and a backend is set up. - defaults to True + defaults to False. force : bool, optional - If True, attempt to switch the backend. This defaults to - False. + If True, attempt to switch the backend. An ImportError is raised if + an interactive backend is selected, but another interactive + backend has already started. This defaults to True. See Also --------