您现在的位置是:课程教程文章
如何用python画圆?使用什么函数来画?
2023-12-18 17:42课程教程文章 人已围观
在Python中,可以利用matplotlb库的“Circle()”来画圆,将其封装到plot_circle函数中调用即可画圆。方法是:1、利用figure确定画布大小;2、利用“Circle()”配置圆的相关信息。
代码如下:
from matplotlib.patches import Ellipse, Circle import matplotlib.pyplot as plt def plot_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') #changes limits of x or y axis so that equal increments of x and y have the same length plt.show() plot_cicle()
课程教程:如何用python画圆?使用什么函数来画?推荐课程:Matplotlib图形绘制(Corey Schafer)
下一篇:没有了