|
From: mogliii <mo...@gm...> - 2012-09-06 14:59:02
|
<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix">On 06/09/2012 14:49, Benjamin Root
wrote:<br>
</div>
<blockquote
cite="mid:CAN...@ma..."
type="cite"><br>
<br>
<div class="gmail_quote">On Thu, Sep 6, 2012 at 6:54 AM, Mogliii <span
dir="ltr"><<a moz-do-not-send="true"
href="mailto:mo...@gm..." target="_blank">mo...@gm...</a>></span>
wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">
<div text="#000000" bgcolor="#FFFFFF"> Hi,<br>
<br>
I am preparing figures with the following matplotlib
preamble:<br>
<br>
plt.rc('font', **{'family':'serif', 'serif':['Computer
Modern Roman'],<br>
'monospace':['Computer Modern
Typewriter']})<br>
params = {'backend': 'ps',<br>
'text.latex.preamble': [r"\usepackage{upgreek}",<br>
r"\usepackage[nice]{units}"],<br>
'axes.labelsize': 12,<br>
'text.fontsize': 12,<br>
'legend.fontsize': 8,<br>
'xtick.labelsize': 10,<br>
'ytick.labelsize': 10,<br>
'text.usetex': True,<br>
'figure.figsize': fig_size,<br>
'axes.unicode_minus': True}<br>
plt.rcParams.update(params)<br>
<br>
<br>
But when using subscript and superscript in math mode the
sizes end up different than in my LaTeX document (my .cls is
using "book" as base class).<br>
<br>
Attached are two screenshots of it rendered from matplotlib
and from Latex (sorry for the different sizes). The "mean"
is clearly of different size in relation to the "d".<br>
<br>
<br>
Is there an option to specify a .cls file in rcParams that
should be used for rendering? <br>
I tried: <br>
text.latex.preamble': [r"\documentclass[twoside]{mycls}",<br>
r"\usepackage{upgreek}",<br>
r"\usepackage[nice]{units}"],<br>
but then I get the error:<br>
! LaTeX Error: Two \documentclass or \documentstyle
commands.<br>
<br>
How to overwrite default matplotlib one? my matplotlibrc has
a commented preamble.<br>
<br>
<br>
<br>
See also my question on <a moz-do-not-send="true"
href="http://tex.stackexchange.com" target="_blank">tex.stackexchange.com</a>:
<a moz-do-not-send="true"
href="http://tex.stackexchange.com/questions/70400/subscript-size-different-in-latex-and-matplotlib"
target="_blank">http://tex.stackexchange.com/questions/70400/subscript-size-different-in-latex-and-matplotlib</a><br>
<br>
<br>
<br>
Many thanks<br>
</div>
<br>
</blockquote>
<div><br>
This might have been fixed at one point. Which version of
matplotlib are you using?<br>
<br>
Ben Root<br>
<br>
</div>
</div>
</blockquote>
<br>
I found the solution. My LaTeX file uses the package amsmath, which
also loads amstext. And that is invoked when using \text{} or
\textnormal{} inside a formula.<br>
<br>
So the solution in matplotlib is to add the following to the
preamble:<br>
'text.latex.preamble': [r"\usepackage{upgreek}",<br>
r"\usepackage[nice]{units}",<br>
<span class="comment-copy"><code>r"\usepackage{amstext}"</code></span>],<br>
<br>
I was using matplotlib 1.1, now updated to 1.1.1, but that did not
affect it. Also, I am not using the built-in LaTeX typesetting.<br>
<br>
<br>
</body>
</html>
|