Fernando Perez wrote:
Please try now, with r5435 or later. There is still the underlying
puzzle to be solved before all this can be cleaned up, but I think the
basic functionality is back.
Eric: in Shell,py, around line 1167, you'll find this code:
backends = {'gthread' : 'GTKAgg',
'wthread' : 'WXAgg',
'qthread' : 'QtAgg',
'q4thread' :'Qt4Agg',
'tkthread' :'TkAgg',
}
That is used to SET the rcParams['backend'] value. I don't know if
that can cause issues.
No, that is OK with old or svn versions of mpl.
But more importantly, I think the problem you see comes from this code
(just a bit later in the same file):
else:
backend = matplotlib.rcParams['backend']
if backend.startswith('GTK'):
th_mode = 'gthread'
elif backend.startswith('WX'):
th_mode = 'wthread'
elif backend.startswith('Qt4'):
th_mode = 'q4thread'
elif backend.startswith('Qt'):
th_mode = 'qthread'
else:
# Any other backend, use plain Tk
th_mode = 'tkthread'
return mpl_shell[th_mode]
Yes, I was looking for this sort of thing but managed to miss it yesterday. This is where the problem is. The workaround that I have in mpl svn now is to simply retain the mixed cases (although the input and checking are completely case-insensitive). My suggested change for ipython, so that some day mpl would not need to retain the mixed cases, is in the attached diff against ipython svn. Fairly quick checks against mpl svn, mpl svn with all lower case, and mpl maintenance branch indicated that this change would be backwards and forwards compatible, so long as mpl retains rcsetup.validate_backend().
It also makes it so that you could go to lower case in:
backends = {'gthread' : 'GTKAgg',
'wthread' : 'WXAgg',
'qthread' : 'QtAgg',
'q4thread' :'Qt4Agg',
'tkthread' :'TkAgg',
}
and this should also be backwards and forwards compatible; by using validate_backend when setting the backend, one ensures that rcParams gets a form that the particular version of mpl is happy with.
You might be able to use matplotlib.use(backends[th_mode]) to replace
the following in my suggested diff, provided you have not already performed some magic that would foil the sys.modules checking done by matplotlib.use():
backend = mrcsetup.validate_backend(backends[th_mode])
matplotlib.rcParams['backend'] = backend
The rationale for using "matplotlib.use" and "matplotlib.get_backend" is that they can take advantage of validation that is not available when you directly get and set the rcParams value. On the other hand there is some appeal in the directness of going straight to/from rcParams.
Anyway, regardless of whether you decide to make any changes in ipython, thanks for solving the puzzle.
Eric
ipython_diff1 (1.43 KB)
···
On Mon, Jun 9, 2008 at 10:16 AM, Eric Firing <efiring@...229...> wrote:
IPython does an explicit check on the names of the backends with that
exact capitalization. I could add a .lower() call to the line that
starts:
backend = matplotlib.rcParams['backend'].lower()
and change the .startswith() calls to do all lowercase checks. Could
you see if that helps? That would make the fix backwards compatible.
Cheers,
f