| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
See changes documented in the API changes file. Some followup cleanup (of the now unused old machinery) will come as a separate PR (left some "FIXME: Remove." comments). Changes to the build process (namely, getting rid of trying to detect the default backend in setupext.py) will come as a separate PR. I inlined pylab_setup into switch_backend (and deprecated the old version of pylab_setup) because otherwise the typical call stack would be `use()` -> `set rcParams['backend'] = ...` -> `switch_backend()` -> `pylab_setup()`, which is a bit of a mess; at least we can get rid of one of the layers.
The selection logic is now described in the module's docstring. The only changes is that the QT_ENV_MAJOR_VERSION global, which would sometimes be defined (depending on the state of the import cache, the QT_API environment variable, and the requested backend) is never defined anymore.
|
The matplotlib.use API has been there from 2004 (goes all the way back to e34a333) and it is in a lot of code / documentation / examples. I am not convinced that the slight improvement in the verbiage is worth disrupting a considerable fraction of our users. While if we were going to be starting from a clean slate I agree set_backend is a better name, I am 👎 on deprecating use. I am 50/50 on adding set_backend as an alias for use, it is a better more guessable name, but now we have 2 versions of the call... Similarly, storing the current backend in rcParams has been there as long, ex the current implementation of get_backend is: matplotlib/lib/matplotlib/__init__.py Lines 1380 to 1382 in e3042ab I think I am on board with pushing people to get_backend instead of rcParams['backend'], but that is going to need a long (multi-year) deprecation cycle. I am 👍 on adding 'default_backends' as a parameter, but (as discussed on the call today) we may want to move things like backend, interactive, etc out of rcParams all together so we should have a plan for that before we put it in. |
Sorry, something went wrong.
|
The changes are rather independent and could be introduced incrementally, if we are not sure about some of them:
A reasonable minimal start for 3.0 could be just to do 1. (and maybe 4.) - acknowledging that the original PRs #11581 and #11600 are tagged 3.0 and release-critical. The other points seem to be more controversial and there is no need to rush it. |
Sorry, something went wrong.
| try: | ||
| switch_backend(candidate) | ||
| except ImportError: | ||
| continue |
There was a problem hiding this comment.
probably need to do something if no backend is successfully imported.
Sorry, something went wrong.
| cbook.warn_deprecated('3.0', | ||
| "The rcParam 'backend' is deprecated. Use the rcParam " | ||
| "'default_backends' to access the defaults. Use get_backend() " | ||
| "to get the current backend.") |
There was a problem hiding this comment.
But then you need to store the current backend somewhere else and update the implementation of get_backend accordingly.
Sorry, something went wrong.
|
@timhoffm I agree with your suggestions above. OTOH for now we want to get backend switching in, and the existing rcParam stuffing, while suboptimal, is the existing API. So for 3.0 I think we decided to move along w/ @anntzer PR (plus or minus any review changes) and then we can re-open the deprecation/API refinement for 3.1 (due December-ish). |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
PR Summary
This PR creates a possible API for backend switching. The API is laid out in the last commit. Previous commits are from #11600 and only contain the actual switching logic.
The code is not fully tested. It's main purpose is to give an idea how the following API can be implemented:
Typical use-cases:
Setting the default backend
new API:
current API (deprecated):
Setting the current backend
new API:
matplotlib.set_backend('qt5agg')current API (deprecated):
matplotlib.use('qt5agg') WARNING: matplotlib.use is deprecated. Use matplotlib.set_backend instead.Querying the current backend:
new API:
current API (deprecated):