Hi John,
> the y-axis has a different font (italic) than the x-axis
> (sans-serif). Looking at the code, this is because it is
> set as math text ( \.\.\.). Is there a trick to ensure a
> sans-serif font for the y-axis? (I would like to use
> matplotlib plots in a presentation and sans-serif fonts are
> better suited for this.)
What version of mpl are you using? I thought in a previous post you
said you were using cvs (could be mistaken).
You remember the version I am running better than I do ;-).
In [1]: import matplotlib
In [2]: matplotlib.__version__
Out[2]: '0.84.cvs.2'
I wrote an extension to
text.py to special case exponential formatting specifically to solve
the mismatched fonts problem. So make sure you are using a current
problem of matplotlib and if you still have the problem check your
input against the regex in matplotlib.text.Text
# special case superscripting to speedup logplots
_rgxsuper = re.compile('\$([\-+0-9]+)\^\{(-?[0-9]+)\}\$')
If you can fix up this expression to include your case that would be
most helpful.
I think the expression is alright:
I looked at matplotlib/text.py - class Text. It seems that
for this example the routine does not pass by the
first use of self._rgxsuper:
print "Arriving here1"
if angle==0:
print "Arriving here2"
if ismath!='TeX': # <==== change to "==" here?
print "Arriving here3"
m = None
else:
m = self._rgxsuper.match(self._text)
print "passing by here..."
print "Arriving here4"
if m is not None and not rcParams['text.usetex']:
print "Arriving here5"
bbox, info = self._get_layout_super(self._renderer, m)
base, xt, yt = info[0]
renderer.draw_text(gc, xt, yt, base,
self._fontproperties, angle,
ismath=False)
exponent, xt, yt, fp = info[1]
renderer.draw_text(gc, xt, yt, exponent,
fp, angle,
ismath=False)
return
However, changing ismath!='TeX' to ismath=='TeX'
seems to work (for this particular example): I.e. I get
the non-math fonts on the vertical axis.
Can you confirm that this change is the correct solution?
Best,
Arnd
P.S.: BTW: splattering the prints around seems like poor-mans
debugging Are there better solutions available?
···
On Sat, 3 Sep 2005, John Hunter wrote: