1.源码实现
import matplotlib.pyplot as plt
fig = plt.figure(figsize=(6,3))
ax = fig.add_subplot(111)
# 除掉刻度
ax.set_xticks([])
ax.set_yticks([])
# 除掉四条边
ax.spines['left'].set_color('none')
ax.spines['right'].set_color('none')
ax.spines['bottom'].set_color('none')
ax.spines['top'].set_color('none')
# 添加文字公式
ax.text(0.1, 0.45, r'$ \frac{x^2}{a^2} + \frac{y^2}{b^2} = 1 (a>b>0) $', fontsize=28)
plt.savefig("test.png")
2.运行程序
$ python3 example.py
网友评论