matplotlib, usetex

Alexander Schmolck a.schmolck at gmail.com
Sun May 27 10:00:30 EDT 2007


Bill Jackson <jackson at hotmail.com> writes:

> Alexander Schmolck wrote the following on 05/25/2007 02:33 PM:
>> I have no idea whether this will resolve your problem, but you could try
>> updating to 0.90 (BTW what happens if you do axis([0,128,0,128])).
>
> The problem appears to be with a matplotlibrc file.  If I delete the
> matplotlibrc file, then I am able to plot perfectly.  Thus, it appears that I
> am unable to specify usetex from my configuration file.  Why is this
> happening?
>
> ---- ~/.matplotlib/matplotlibrc ----
> text.usetex	: True
>
> ---- test.py ----
> import matplotlib
> import pylab
> matplotlib.rc('text', usetex=True)

I think it might be a good habit to develop to call ``rc`` before ``import
pylab`` -- some things won't take effect otherwise (this doesn't affect all
parameters and will likely be eventually fixed in general, but notably it does
currently affect some latex-related stuff, such as font choice).

> pylab.plot(range(10))
> pylab.show()
>
>
> Running 'python test.py' with the above matplotlibrc causes the errors in my
> original post.  Deleting matplotlibrc resolves the problem.

I can't see any problem with you matplotlibrc; what happens if you swap around
the lines as I suggested above? Maybe it just appears to work, because the
usetex really does have no affect above, and you really are not using latex?

I have been using matplotlib with latex for fonts handling for some time now
(and I've even submitted a patch to ameliorate the rc problem mentioned
above), but the latex stuff has changed somewhat over time, and still has some
rough edges -- so for not immediately obvious problems with the latex handling
of an older version of matplotlib you're much more likely to find someone who
has the relevant details mentally available on the matplotlib-disc list are
much better than here; so I'd recommend you give it a try again (yeah sf is a
pain).

cheers,

'as






More information about the Python-list mailing list