在Python中,可以利用matplotlb库的“Circle()”来画圆,将其封装到plot_circle函数中调用即可画圆。方法是:1、利用figure确定画布大小;2、利用“Circle()”配置圆的相关信息。

代码如下:
frommatplotlib.patchesimportEllipse,Circle
importmatplotlib.pyplotasplt
defplot_cicle():
fig=plt.figure()
ax=fig.add_subplot(111)
cir1=Circle(xy=(0.0,0.0),radius=2,alpha=0.5)
ax.add_patch(cir1)
x,y=0,0
ax.plot(x,y,'ro')
plt.axis('scaled')
plt.axis('equal')#changeslimitsofxoryaxissothatequalincrementsofxandyhavethesamelength
plt.show()
plot_cicle()
原文来自:https://www.py.cn © 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END


















































暂无评论内容