-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
matplotlibrc: is there a way to specify "backend" as either "Qt5Agg | Qt4Agg" (whatever is installed)? #8613
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I think this is a very good idea. The places to fix this would be:
|
Alright, thanks for directions, I'll have a look. Appropriate base branch would be |
Yeah, this would go in for 2.1, too big of a change for a patch release. |
So if I just add it in those two places mpl complains because it tries to lookup Should I put a dummy |
Sorry, I missed a step in how the backend lookup works 😞 🐑 . Putting in a The other option I see is to hack at |
What about letting backend just be a list of tentative backends that are tried one after the other? |
@anntzer I like that idea better than what I suggested. |
Sounds good to me, I guess the process of trying one backend or the other doesn't hamper selecting a usable backend anymore? Back in the old days, selecting a backend sometimes used to be a one-shot operation.. e.g. when running some server scripts it was essential to select "AGG" ( |
It is better than it used to be, but not totally fixed. You can always
switch to a non-interactive backend at just about any time (it is how we
save to pdf, eps, etc..), but you can't reliably switch interactive
backends once pyplot is imported. Importing pyplot triggers the function
"pylab_setup()", which does some magic. In some cases, you can switch the
interactive backends after pyplot is imported, but I don't think we have
extensive testing of that feature.
One of the caveats I would have with the suggested approach is that there
exists code in the wild (and possibly within mpl itself, I can't remember),
that queries the list of imported modules so far and figures out which GUI
toolkit to use based on what it finds in that list. If we have failed
attempts to import a toolkit, the failed imports might leave behind partial
imports in the tree, which may confuse some of those algorithms.
…On Mon, May 15, 2017 at 5:19 AM, Tobias Megies ***@***.***> wrote:
Sounds good to me, I guess the process of trying one backend or the other
doesn't hamper selecting a usable backend anymore? Back in the old days,
selecting a backend sometimes used to be a one-shot operation.. e.g. when
running some server scripts it was essential to select "AGG" at the top of
the file before any pyplot imports because switching was often not possible
anymore once one backend was imported..?
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#8613 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AARy-Mlwa16WMLV8ZilHzrz7UGHHQ0Ydks5r6BitgaJpZM4NZUc1>
.
|
Thanks for the feedback @WeatherGod. This kind of backs my unease with specifying backend in RC as a list. Furthermore changing it to be a list instead of a string for one backend might have other side effects (backwards compatibility etc.). So maybe it would be least invasive to add a stub But I'll wait for more opinions for a while.. |
I am almost certain such approaches are already broken -- one can e.g. manually import tkinter while the backend is Qt5Agg. The correct approach is (currently) to check the value of I think a backcompatible way is to add a plural form |
I was thinking we accept either a list or a string for The multiple backends should be tried in [Edited to add the missing sentence] |
Actually that'd work too. If you want to sniff the actual backend, you read |
hoo, boy... that's gonna get fugly fast...
…On Mon, May 15, 2017 at 12:31 PM, Antony Lee ***@***.***> wrote:
Actually that'd work too. If you want to sniff the actual backend, you
read rcParams["backend"] and if it's a list, it means that matplotlib
hasn't made its choice yet?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#8613 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AARy-BMj4BjR1EJnjAByruIU4Y4og4Ebks5r6H3bgaJpZM4NZUc1>
.
|
Also, don't forget we support specifying a backend through an environment
variable, too!
On Mon, May 15, 2017 at 12:55 PM, Benjamin Root <[email protected]>
wrote:
… hoo, boy... that's gonna get fugly fast...
On Mon, May 15, 2017 at 12:31 PM, Antony Lee ***@***.***>
wrote:
> Actually that'd work too. If you want to sniff the actual backend, you
> read rcParams["backend"] and if it's a list, it means that matplotlib
> hasn't made its choice yet?
>
> —
> You are receiving this because you were mentioned.
> Reply to this email directly, view it on GitHub
> <#8613 (comment)>,
> or mute the thread
> <https://github.com/notifications/unsubscribe-auth/AARy-BMj4BjR1EJnjAByruIU4Y4og4Ebks5r6H3bgaJpZM4NZUc1>
> .
>
|
the environment variable should just force the backend. |
Note that specifying the backends as a list would also solve issues such as #8518 ("the default backend is chosen at build time, and sometimes defaults to a non-interactive backend"): one can just default to e.g. |
Improved, but not closed, by #9795 (there's a fixed fallback list now). |
Closing because Qt4 is deprecated since Matplotlib 3.3. |
I'm not sure this is specifically about Qt4 vs Qt5. However, we have automatic backend selection now, so you could just leave out a backend from matplotlibrc and it would pick whichever one you have in your conda environment. |
I have loads of conda environments in parallel, some of which have Qt4 installed and some have Qt5. I used to have
backend : Qt4Agg
in my~/.config/matplotlib/matplotlibrc
, but nowadays this will get me errors when I'm in one of the Qt5-environments.Ideally I would like to be able to specify
backend : QtAgg
and it should use either Qt5 or Qt4, whatever is available ad hoc.I had a look at the backend selection stuff, but couldn't find how to do it. I'd propose to come up with a PR if somebody could give me a short tip, where to implement such a switch..
The text was updated successfully, but these errors were encountered: