数学文本演示

使用Matplotlib的内部LaTeX解析器和布局引擎。 有关真正的LaTeX渲染,请参阅text.usetex选项。

数学文本演示

  1. import matplotlib.pyplot as plt
  2. fig, ax = plt.subplots()
  3. ax.plot([1, 2, 3], 'r', label=r'$\sqrt{x^2}$')
  4. ax.legend()
  5. ax.set_xlabel(r'$\Delta_i^j$', fontsize=20)
  6. ax.set_ylabel(r'$\Delta_{i+1}^j$', fontsize=20)
  7. ax.set_title(r'$\Delta_i^j \hspace{0.4} \mathrm{versus} \hspace{0.4} '
  8. r'\Delta_{i+1}^j$', fontsize=20)
  9. tex = r'$\mathcal{R}\prod_{i=\alpha_{i+1}}^\infty a_i\sin(2 \pi f x_i)$'
  10. ax.text(1, 1.6, tex, fontsize=20, va='bottom')
  11. fig.tight_layout()
  12. plt.show()

下载这个示例