···
On 08/13/2011 01:11 PM, Vlastimil Brom wrote:
Hi all,
I'd like to ask a probably basic qustion about backends in matplotlib
- specifically with regard to WXAgg and WX.
What are the differences of the two, and what are the supposed
usecases, and maybe restrictions for them?
http://matplotlib.sourceforge.net/faq/installing_faq.html#backends
WXAgg is WX for window and widgets, but with all figure rendering done
using the Agg library to generate an image which is then displayed as
such by WX. There is the same sort of pair for gtk: gtkagg and plain
gtk. Only the *agg interactive backends are fully supported; it is
expected that not everything will work with the non-agg interactive
backends, and every now and then there is discussion of whether they
should be eliminated for that reason. Their only advantage, as far as I
know, is that under some circumstances, such as working remotely with X
on a slow link, the non-agg backends may be faster.
Using matplotlib/pylab pylab in a rather basic way I encountered
problems with both backends and would like to clarify the differences
before i try to find a fix.
using wxAgg I am not able to display unicode text (some accents,
non-latin scripts etc. e.g. in pylab.title(...) and otherwhere .
This is surprising; in general, unicode works with the *agg backends.
Maybe plain WX is finding some fonts that WXAgg is not finding?
Eric
Thanks for the reference and for the important info, that only wxagg
is considered fully supported as opposed to wx backend.
It appears, that in the current state, using the latest wxpython
2.9.2.1, it is indeed unusable, as no graph canvas is displayed at all
(at least on my setup - win 7, py-2.7), cf.:
####################################################
#! Python
# -*- coding: utf-8 -*-
import wxversion
# wxversion.select('2.9.1') # 2.9.1.1 # plot ok
wxversion.select('2.9.2') # 2.9.2.1 # invalid "transparent" canvas
without any graph content
import wx
import matplotlib
matplotlib.use('WX')
import pylab
pylab.plot(range(3), range(3))
pylab.show()
####################################################
Regarding wxagg, it seems, that the suggestion about unsuitable fonts
being used was correct;
after setting the font to Arial, adapted from:
http://matplotlib.sourceforge.net/examples/api/font_family_rc.html
all the characters in the title are displayed ok.
####################################################
#! Python
# -*- coding: utf-8 -*-
import wxversion
wxversion.select('2.9.2') # 2.9.2.1
import wx
# setting the font to Arial - the title is displayed completely;
# with the default font only the "latin-1" characters are shown
from matplotlib import rcParams
rcParams['font.family'] = 'sans-serif'
rcParams['font.sans-serif'] = ['Arial'] + rcParams['font.sans-serif']
#
import matplotlib
matplotlib.use('WXAgg')
import pylab
pylab.plot(range(3), range(3))
pylab.title(u"abcd áčďéěíňóřšťúůýž äöüß ê αβγδ абвгд אבגד xyz")
pylab.show()
####################################################
(using python 2.7.2, MPL 1.0.1; Win 7, Czech)
Is there maybe some machanism available in matplotlib, which would
select the appropriate font for the given characters? (Like in wx or,
even more powerful in tk?) Or is it the expected way to set the
suitable font individually, as only the font list in rcParams are
tried sequentially - regardless of the character support?
Regards,
vbr