From bd1646f397057c671009ac46e150df2ecb667efb Mon Sep 17 00:00:00 2001 From: Jody Klymak Date: Tue, 23 Oct 2018 19:22:14 -0700 Subject: [PATCH 1/3] ENH: allow matplotlib.use after getbackend --- lib/matplotlib/__init__.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/matplotlib/__init__.py b/lib/matplotlib/__init__.py index 168e87ca2837..5eb7d1be142c 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,11 @@ 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. + True. See Also -------- From 52df902b988f8408e2f585dc408473fe33a60ded Mon Sep 17 00:00:00 2001 From: Jody Klymak Date: Wed, 24 Oct 2018 08:41:02 -0700 Subject: [PATCH 2/3] DOC: fix docstring --- lib/matplotlib/__init__.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/matplotlib/__init__.py b/lib/matplotlib/__init__.py index 5eb7d1be142c..a2b16911867f 100644 --- a/lib/matplotlib/__init__.py +++ b/lib/matplotlib/__init__.py @@ -1318,11 +1318,12 @@ def use(arg, warn=False, force=True): If True, warn if this is called after pyplot has been imported and a backend is set up. - defaults to False + defaults to False. force : bool, optional - If True, attempt to switch the backend. This defaults to - True. + 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 -------- From c87e2daa0c2380f2fe1f4856c10b2d827099b91b Mon Sep 17 00:00:00 2001 From: Jody Klymak Date: Wed, 24 Oct 2018 08:49:47 -0700 Subject: [PATCH 3/3] DOC: API changes --- doc/api/next_api_changes/2018-10-24-JMK.rst | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 doc/api/next_api_changes/2018-10-24-JMK.rst 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.