Libertine font in Matplotlib?

Hi all;

I'm using the excellent font Linux Libertine for writing my thesis, in
which I do my plotting in matplotlib. I would really love to be ablu to
have consistent fonts in both text and graphs - is this possible? I know
it can be loaded by \usepackage{libertine}.

Best;

Emil

From: Thøger Emil Juul Thorsen [mailto:thoeger@…845…]
Sent: Monday, October 18, 2010 14:04

I'm using the excellent font Linux Libertine for writing my thesis, in
which I do my plotting in matplotlib. I would really love to
be ablu to
have consistent fonts in both text and graphs - is this
possible? I know
it can be loaded by \usepackage{libertine}.

For ordinary text objects, one way is to set the font.family rcParam to the
font name. You could do this either in a matplotlibrc file in an appropriate
location or in your code dynamically [1]. If you'll be using mathtext, also
see the "Fonts" section and "Custom fonts" subsection at [2]; for LaTeX, [3].

[1] http://matplotlib.sourceforge.net/users/customizing.html

[2] http://matplotlib.sourceforge.net/users/mathtext.html#fonts

[3] http://matplotlib.sourceforge.net/users/usetex.html

Sorry, perhaps I should have specified;

I'm using usetex, and Libertine is not among the supported fonts. In the
example RC file, it said that if any font was wanted, that could be
loaded with a \usepackage command, one should request it on the mailing
list.

···

On Wed, 2010-10-20 at 14:29 -0400, Stan West wrote:

> From: Thøger Emil Juul Thorsen [mailto:thoeger@…845…]
> Sent: Monday, October 18, 2010 14:04
>
> I'm using the excellent font Linux Libertine for writing my thesis, in
> which I do my plotting in matplotlib. I would really love to
> be ablu to
> have consistent fonts in both text and graphs - is this
> possible? I know
> it can be loaded by \usepackage{libertine}.

For ordinary text objects, one way is to set the font.family rcParam to the
font name. You could do this either in a matplotlibrc file in an appropriate
location or in your code dynamically [1]. If you'll be using mathtext, also
see the "Fonts" section and "Custom fonts" subsection at [2]; for LaTeX, [3].

[1] http://matplotlib.sourceforge.net/users/customizing.html

[2] http://matplotlib.sourceforge.net/users/mathtext.html#fonts

[3] http://matplotlib.sourceforge.net/users/usetex.html

You might be able to do this (before importing pyplot or pylab):

matplotlib.rcParams['text.usetex'] = True
matplotlib.rcParams['text.latex.preamble'] = '\usepackage{libertine}'

and optionally (if you have xpdf or poppler installed):

matplotlib.rcParams['ps.usedistiller'] = 'xpdf'

Good luck,
Jeff

···

On Oct 20, 2010, at 3:32 PM, Thøger Emil Juul Thorsen wrote:

Sorry, perhaps I should have specified;

I'm using usetex, and Libertine is not among the supported fonts. In the
example RC file, it said that if any font was wanted, that could be
loaded with a \usepackage command, one should request it on the mailing
list.

On Wed, 2010-10-20 at 14:29 -0400, Stan West wrote:

From: Thøger Emil Juul Thorsen [mailto:thoeger@…845…]
Sent: Monday, October 18, 2010 14:04

I'm using the excellent font Linux Libertine for writing my thesis, in
which I do my plotting in matplotlib. I would really love to
be ablu to
have consistent fonts in both text and graphs - is this
possible? I know
it can be loaded by \usepackage{libertine}.

For ordinary text objects, one way is to set the font.family rcParam to the
font name. You could do this either in a matplotlibrc file in an appropriate
location or in your code dynamically [1]. If you'll be using mathtext, also
see the "Fonts" section and "Custom fonts" subsection at [2]; for LaTeX, [3].

[1] http://matplotlib.sourceforge.net/users/customizing.html

[2] http://matplotlib.sourceforge.net/users/mathtext.html#fonts

[3] http://matplotlib.sourceforge.net/users/usetex.html

------------------------------------------------------------------------------
Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store
http://p.sf.net/sfu/nokia-dev2dev
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options