Python 画椭圆
import matplotlib.pyplot as plt
from matplotlib.patches import Ellipse
fig, ax = plt.subplots()
# 创建一个椭圆对象,参数分别是:中心坐标(x, y),宽高(2*a, 2*b),旋转角度theta
ellipse = Ellipse(xy=(0, 0), width=8, height=4, angle=45, edgecolor='blue', fill=False, linestyle=':', linewidth=4)
注意:width、height这里是直径!!!
# 将椭圆添加到坐标轴上
ax.add_patch(ellipse)
# 设置坐标轴的范围
ax.set_xlim(-10, 10)
ax.set_ylim(-10, 10)
# 显示图形
plt.show()
评论已关闭