美文网首页
matplotlib绘制椭圆的数学公式

matplotlib绘制椭圆的数学公式

作者: 一路向后 | 来源:发表于2020-12-29 21:59 被阅读0次

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

3.执行结果

test.png

相关文章

网友评论

      本文标题:matplotlib绘制椭圆的数学公式

      本文链接:https://www.haomeiwen.com/subject/cagqoktx.html