Issues with TeX symbols and font changes

Originally emailed this off to the wrong list, but any help would be much appreciated!

···

---------- Forwarded message ----------
From: Kacey A. <intel.g33k@…287…>

Date: Wed, Apr 16, 2008 at 8:44 PM

Subject: Issues with TeX symbols and font changes
To: scipy-user@…177…

Hello all,

I’ve spent more time than I care to share trying to remedy this, but it just doesn’t seem to be working… So long story short, I’m trying to insert a special symbol in my axis label, so I type the following:

[1] xlabel = (r"Wavelength ($\AA$)")

…in order to receive the symbol for angstroms (an “A” with a circle above it). Problem is… whereas the rest of my plot is in whatever the default Scipy plot font is (Tahoma, perhaps?), the stubborn angstroms symbol is in Times New Roman-esque font, which is bothering me to no end. I’ve attempted just changing the font of the entire font by using

[2] font = {“fontname”:“Times New Roman”}

[3] xlabel = (ur"Wavelength ($\AA$)", **font)

…but unfortunately that does nothing to affect the font of the axis tickmark labels (i.e. the numbers along the axes) – so while my axis labels (excluding the angstrom symbol) and plot text (i.e. text(x,y,string)) might be in the font set via command [2], the axis numbering will still be in the default (i.e. Tahoma).

For what help it’s worth, I’m running OS X (10.4.11) and Python 2.5.1, although I’m not 100% certain of what version of Scipy and Numpy I have installed… (I think I’m running Scipy 0.3.2). I’m also using TextMate to type and run my scripts.

Thanks so much for any help in advance! I really love SciPy, but if there’s really no feasible workaround for this… I might just have to use a different package altogether. Thanks again.

Kacey A. wrote:

Originally emailed this off to the wrong list, but any help would be much appreciated!

From: *Kacey A.* <intel.g33k@…287… <mailto:intel.g33k@…287…>>
Date: Wed, Apr 16, 2008 at 8:44 PM
Subject: Issues with TeX symbols and font changes
To: scipy-user@…177… <mailto:scipy-user@…177…>

Hello all,

I've spent more time than I care to share trying to remedy this, but it just doesn't seem to be working... So long story short, I'm trying to insert a special symbol in my axis label, so I type the following:

[1] xlabel = (r"Wavelength ($\AA$)")

...in order to receive the symbol for angstroms (an "A" with a circle above it). Problem is... whereas the rest of my plot is in whatever the default Scipy plot font is (Tahoma, perhaps?),

The default font is Bitstream Vera Sans.

the stubborn angstroms symbol is in Times New Roman-esque font, which is bothering me to no end. I've attempted just changing the font of the entire font by using

[2] font = {"fontname":"Times New Roman"}
...
[3] xlabel = (ur"Wavelength ($\AA$)", **font)

...but unfortunately that does nothing to affect the font of the axis tickmark labels (i.e. the numbers along the axes) -- so while my axis labels (excluding the angstrom symbol) and plot text (i.e. text(x,y,string)) might be in the font set via command [2], the axis numbering will *still* be in the default (i.e. Tahoma).

To change the font globally (excluding mathtext), you can do:

  rc('font', family='Times New Roman')

For what help it's worth, I'm running OS X (10.4.11) and Python 2.5.1, although I'm not 100% certain of what version of Scipy and Numpy I have installed... (I *think* I'm running Scipy 0.3.2). I'm also using TextMate to type and run my scripts.

Thanks so much for any help in advance! I really love SciPy, but if there's really no feasible workaround for this... I might just have to use a different package altogether. Thanks again.

When using mathtext (putting symbols inside of a pair of $), unfortunately the font choices are rather limited. You basically have a choice of Computer Modern (used in TeX/LaTeX documents), STIX (which is based on Times), and STIX sans (which is sans-serif, based on some font I haven't been able to identify). This font can be set with the mathtext.fontset rcParam (to one of cm, stix, stixsans or custom).

Fortunately, all is not lost. If all you need to is an Angstrom symbol, you can use Unicode rather than mathtext. The code point for � (A with ring above) is C5 -- so you can type the following string in Python:

    ur"Wavelength (\u00c5)"

I hope that one of these options will prove helpful.

Cheers,
Mike

···

---------- Forwarded message ----------

--
Michael Droettboom
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA

Oh my goodness, thank you so much! I honestly can’t thank you enough, you’ve saved my thesis! I now have beautiful Angstrom symbols for my plots! And the tips for changing the regular and mathtext fonts work like a charm. Simply amazing.

I’m done gushing now, but thank you so much again!

···

On Thu, Apr 17, 2008 at 8:17 AM, Michael Droettboom <mdroe@…86…> wrote:

Kacey A. wrote:

Originally emailed this off to the wrong list, but any help would be much appreciated!

---------- Forwarded message ----------

From: Kacey A. <intel.g33k@…287… mailto:intel.g33k@...287...>

Date: Wed, Apr 16, 2008 at 8:44 PM

Subject: Issues with TeX symbols and font changes

To: scipy-user@…878…177… mailto:scipy-user@...177...

Hello all,

I’ve spent more time than I care to share trying to remedy this, but it just doesn’t seem to be working… So long story short, I’m trying to insert a special symbol in my axis label, so I type the following:

[1] xlabel = (r"Wavelength ($\AA$)")

…in order to receive the symbol for angstroms (an “A” with a circle above it). Problem is… whereas the rest of my plot is in whatever the default Scipy plot font is (Tahoma, perhaps?),

The default font is Bitstream Vera Sans.

the stubborn angstroms symbol is in Times New Roman-esque font, which is bothering me to no end. I’ve attempted just changing the font of the entire font by using

[2] font = {“fontname”:“Times New Roman”}

[3] xlabel = (ur"Wavelength ($\AA$)", **font)

…but unfortunately that does nothing to affect the font of the axis tickmark labels (i.e. the numbers along the axes) – so while my axis labels (excluding the angstrom symbol) and plot text (i.e. text(x,y,string)) might be in the font set via command [2], the axis numbering will still be in the default (i.e. Tahoma).

To change the font globally (excluding mathtext), you can do:

rc(‘font’, family=‘Times New Roman’)

For what help it’s worth, I’m running OS X (10.4.11) and Python 2.5.1, although I’m not 100% certain of what version of Scipy and Numpy I have installed… (I think I’m running Scipy 0.3.2). I’m also using TextMate to type and run my scripts.

Thanks so much for any help in advance! I really love SciPy, but if there’s really no feasible workaround for this… I might just have to use a different package altogether. Thanks again.

When using mathtext (putting symbols inside of a pair of $), unfortunately the font choices are rather limited. You basically have a choice of Computer Modern (used in TeX/LaTeX documents), STIX (which is based on Times), and STIX sans (which is sans-serif, based on some font I haven’t been able to identify). This font can be set with the mathtext.fontset rcParam (to one of cm, stix, stixsans or custom).

Fortunately, all is not lost. If all you need to is an Angstrom symbol, you can use Unicode rather than mathtext. The code point for Å (A with ring above) is C5 – so you can type the following string in Python:

ur"Wavelength (\u00c5)"

I hope that one of these options will prove helpful.

Cheers,

Mike

Michael Droettboom

Science Software Branch

Operations and Engineering Division

Space Telescope Science Institute

Operated by AURA for NASA