Problem getting math symbols into text

Greetings. I'm unable to get mathtext to work properly on my linux system:

    # cat /etc/redhat-release
    Fedora release 13 (Goddard)

    # uname -a
    Linux localhost.localdomain 2.6.33.6-147.2.4.fc13.x86_64 #1 SMP Fri Jul 23
    17:14:44 UTC 2010 x86_64 x86_64 x86_64 GNU/Linux

The problem is essentially identical to one that is described in the thread
at:

http://www.mail-archive.com/matplotlib-users@lists.sourceforge.net/msg09208.html

I didn't see a real resolution to the problem in that thread, at least not one
that applied to me.

In brief, when I specify a math symbol in a text string, say:

    r'$\pi$'

I get some "random" character (capital A in this case) at the place where I'm
supposed to see the Greek letter Pi.

Furthermore, if I try to coerce the use of the Greek letters by setting
"text.markup" to "tex", either interactively or in the rc file, I get an error
saying that it's not a valid parameter:

    Bad key "text.markup" on line 161 in ... matplotlibrc

for instance. This is followed by the message:

    You probably need to get an updated matplotlibrc file from
    http://matplotlib.sf.net/_static/matplotlibrc or from the matplotlib
    source distribution

But the file at that link still contains:

    #text.markup:'plain' # Affects how text, such as titles and labels, are
                          # interpreted by default.
                          # 'plain': As plain, unformatted text
                          # 'tex': As TeX-like text. Text between $'s
                          # will be
                          # formatted as a TeX math expression.
                          # This setting has no effect when text.usetex
                          # is True.
                          # In that case, all text will be sent to TeX
                          # for
                          # processing.

I don't know what to make of this. I did the following to try to pin down the
parameters:

    import matplotlib as mpl
    import pprint
    x = mpl.rcParams.keys()
    x.sort()
    pprint.pprint(x)

This produced:

    .
    .
    .
    'svg.image_noscale',
    'text.color',
    'text.dvipnghack',
    'text.fontangle',
    'text.fontsize',
    'text.fontstyle',
    'text.fontvariant',
    'text.fontweight',
    'text.latex.preamble',
    'text.latex.preview',
    'text.latex.unicode',
    'text.usetex',
    'timezone',
    .
    .
    .

Indeed, there does not seem to be a "text.markup" in this list.

I have tried this both with and without an rc file, and I've tried it after
deleting completely my .matplotlib directory. I get the same results in all
cases.

OTOH, if I set:

    text.usetex

to "True", I do get the expected mathematical symbols, albeit after a noticeable
delay.

I've got the following two matplotlib packages installed:

    python-matplotlib-0.99.1.2-4.fc13.x86_64
    python-matplotlib-tk-0.99.1.2-4.fc13.x86_64

and the system is running Python 2.6.4.

Any suggestions? Maybe I'm missing a package?

Thanks.

-- Mike

Mike,

Wow, I hadn’t realized that Fedora 13 is carrying a rather old version of matplotlib (~2 years old). I should double-check what version is in rawhide and possibly prod some people to get them to choose a more recent version…

I am not exactly sure what the cause of your problem is, but you could try uninstalling the Fedora packages of matplotlib and install the latest version from source. Unless someone else has a better idea about what the cause of the problem is?

Ben Root

···

On Tue, Aug 3, 2010 at 11:12 PM, Michael Hannon <jm_hannon@…2652…> wrote:

Greetings. I’m unable to get mathtext to work properly on my linux system:

# cat /etc/redhat-release

Fedora release 13 (Goddard)



# uname -a

Linux localhost.localdomain 2.6.33.6-147.2.4.fc13.x86_64 #1 SMP Fri Jul 23

17:14:44 UTC 2010 x86_64 x86_64 x86_64 GNU/Linux

The problem is essentially identical to one that is described in the thread

at:

http://www.mail-archive.com/matplotlib-users@lists.sourceforge.net/msg09208.html

I didn’t see a real resolution to the problem in that thread, at least not one

that applied to me.

In brief, when I specify a math symbol in a text string, say:

r'$\pi$'

I get some “random” character (capital A in this case) at the place where I’m

supposed to see the Greek letter Pi.

Furthermore, if I try to coerce the use of the Greek letters by setting

“text.markup” to “tex”, either interactively or in the rc file, I get an error

saying that it’s not a valid parameter:

Bad key "text.markup" on line 161 in ... matplotlibrc

for instance. This is followed by the message:

You probably need to get an updated matplotlibrc file from

[http://matplotlib.sf.net/_static/matplotlibrc](http://matplotlib.sf.net/_static/matplotlibrc) or from the matplotlib

source distribution

But the file at that link still contains:

#text.markup:'plain'  # Affects how text, such as titles and labels, are

                      # interpreted by default.

                      # 'plain': As plain, unformatted text

                      # 'tex': As TeX-like text.  Text between $'s

                      # will be

                      # formatted as a TeX math expression.

                      # This setting has no effect when text.usetex

                      # is True.

                      # In that case, all text will be sent to TeX

                      # for

                      # processing.

I don’t know what to make of this. I did the following to try to pin down the

parameters:

import matplotlib as mpl

import pprint

x = mpl.rcParams.keys()

x.sort()

pprint.pprint(x)

This produced:

.

.

.

'svg.image_noscale',

'text.color',

'text.dvipnghack',

'text.fontangle',

'text.fontsize',

'text.fontstyle',

'text.fontvariant',

'text.fontweight',

'text.latex.preamble',

'text.latex.preview',

'text.latex.unicode',

'text.usetex',

'timezone',

.

.

.

Indeed, there does not seem to be a “text.markup” in this list.

I have tried this both with and without an rc file, and I’ve tried it after

deleting completely my .matplotlib directory. I get the same results in all

cases.

OTOH, if I set:

text.usetex

to “True”, I do get the expected mathematical symbols, albeit after a noticeable

delay.

I’ve got the following two matplotlib packages installed:

python-matplotlib-0.99.1.2-4.fc13.x86_64

python-matplotlib-tk-0.99.1.2-4.fc13.x86_64

and the system is running Python 2.6.4.

Any suggestions? Maybe I’m missing a package?

Thanks.

– Mike

Wow, I hadn’t realized that Fedora 13 is carrying a rather old version of
matplotlib (~2 years old). I should double-check what version is in rawhide
and possibly prod some people to get them to choose a more recent version…

Hi, Ben. I think it would be a good idea to give the Fedora people some
feedback on this. I thought that one of the main points of Fedora was to
explore bleeding-edge software.

I am not exactly sure what the cause of your problem is, but you could try
uninstalling the Fedora packages of matplotlib and install the latest
version from source. Unless someone else has a better idea about what the
cause of the problem is?

I’m usually reluctant to do this, as the packages
installed from source don’t
automatically get security updates, etc., but I tried your suggestion and
found the exercise painless. And with the new version I DO get math symbols
on my plots.

Thanks for your help with this.

– Mike

Wow, I hadn’t realized that Fedora 13 is carrying a rather old version of
matplotlib (~2 years old). I should double-check what version is in rawhide

and possibly prod some people to get them to choose a more recent version…

Hi, Ben. I think it would be a good idea to give the Fedora people some
feedback on this. I thought that one of the main points of Fedora was to

explore bleeding-edge software.

Maybe, way in the future there will be source-based custom Fedora builds where all the OS code and the packages will be build from their repositories according to one’s need. For the time being I like following these three easy steps on my FC12 for the latest matplotlib:

svn co https://matplotlib.svn.sourceforge.net/svnroot/matplotlib/trunk/matplotlib matplotlib
python setupegg.py develop (one time only)

svn up

It’s good to see some other fellow Fedora users around in these lists. It will somewhat off-the-topic but what are your impressions of Python and FC13 combination?

I am not exactly sure what the cause of your problem is, but you could try
uninstalling the Fedora packages of matplotlib and install the latest

version from source. Unless someone else has a better idea about what the
cause of the problem is?

I’m usually reluctant to do this, as the packages
installed from source don’t
automatically get security updates, etc., but I tried your suggestion and
found the exercise painless. And with the new version I DO get math symbols
on my plots.

Thanks for your help with this.

– Mike

For the mathtext problem for inclusion of simple math texts you could easily construct your formulas or units using unicode text. Adding # -- coding: utf-8 -- on top of your scripts and then: plt.ylabel(u"π") will do the trick.

···

On Wed, Aug 4, 2010 at 8:05 PM, Michael Hannon <jm_hannon@…9…> wrote:


The Palm PDK Hot Apps Program offers developers who use the

Plug-In Development Kit to bring their C/C++ apps to Palm for a share

of $1 Million in cash or HP Products. Visit us here for more details:

http://p.sf.net/sfu/dev2dev-palm


Matplotlib-users mailing list

Matplotlib-users@lists.sourceforge.net

https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Gökhan