python - IPython 笔记本 : Plotting with LaTeX?

标签 python matplotlib latex ipython jupyter-notebook

在 IPython Notebook 中显示 LaTeX 线条之前已经回答过,但是在 IPython Notebook 中绘图时,如何用 LaTeX 字符串标记绘图的轴?

最佳答案

它在 IPython 中的工作方式与在独立脚本中的工作方式相同。本例来自the docs :

import matplotlib as mpl
import matplotlib.pyplot as plt
mpl.rc('text', usetex = True)
mpl.rc('font', family = 'serif')
plt.figure(1, figsize = (6, 4))
ax = plt.axes([0.1, 0.1, 0.8, 0.7])
t = np.arange(0.0, 1.0+0.01, 0.01)
s = cos(2*2*pi*t)+2
plt.plot(t, s)

plt.xlabel(r'\textbf{time (s)}')
plt.ylabel(r'\textit{voltage (mV)}', fontsize = 16)
plt.title(r"\TeX\ is Number $\displaystyle\sum_{n=1}^\infty\frac{-e^{i\pi}}{2^n}$!",
      fontsize = 16, color = 'r')
plt.grid(True)
plt.savefig('tex_demo')
plt.show()

enter image description here

关于python - IPython 笔记本 : Plotting with LaTeX?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14389892/

相关文章:

python - Matplotlib 和检查按钮定制

matplotlib - 在哪里可以找到有关 Matplotlib 中 AxesSubplot 的文档?

python - 子类化属性在 __init__ 上引发 TypeError

python - 以最小尺寸分割的字符串

python - matplotlib 中带垂直线的图例

r - 空间滞后模型影响的 texreg 表

latex - 如何在 Latex 投影仪讲义中的幻灯片周围绘制边框

latex - 如何转义命令参数中的字符串

python - Python egg 文件有什么意义?

python - Gzip 到 base64 编码将字符添加到 JSON 字符串