对准matplotlib的TeX公式 [英] Align TeX equations in matplotlib

查看:249
本文介绍了对准matplotlib的TeX公式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下行注释的TeX我的 matplotlib 图:

I have the following lines to annotate TeX on my matplotlib plot:

import matplotlib.pyplot as plt
from matplotlib import rc

rc('text', usetex=True)
rc('font', family='serif')

r = 1
v = 2
i = 3

notes = r"\noindent$R_L = {0}\\ V_2 = {1}\\ I_2 = {2}$".format(r, v, i)
plt.annotate(notes, xy=(5,5), xytext=(7,7))
plt.show()

如何让我的等号对准对方?我尝试了多种方法,如 \开始{对齐} &安培; -placement,但我不完全得到它的权利。

How do I make the equals signs align to each other? I experimented with several methods like \begin{align}, &-placement, but I don't quite get it right.

推荐答案

使用 eqnarray的。 你的code的简化版本:

Use eqnarray. A simplified version of your code:

#!/usr/bin/python
import matplotlib.pyplot as plt
from matplotlib import rc

rc('text', usetex=True)
rc('font', family='serif')

r = 1
v = 2
i = 3

plt.plot([1,2,3],[2,3,4],'ro-')

plt.text(2,2,r"\begin{eqnarray*}R_L&= 0\\ V_2&= 1\\ I_2&= 2\end{eqnarray*}")

#notes = r"\noindent$$R_L = {0}\\ V_2 = {1}\\ I_2 = {2}$$".format(r, v, i)
#plt.annotate(notes, xy=(5,5), xytext=(7,7))
plt.show()

要得到它的工作我必须安装dvipng(这里建议,的http:// matplotlib。 sourceforge.net/users/usetex.html

To get it working I had to install dvipng (as suggested here, http://matplotlib.sourceforge.net/users/usetex.html)

这篇关于对准matplotlib的TeX公式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆