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