Home >Backend Development >Python Tutorial >What function is used to draw a circle in Python?
Python draws a circle using the figure() and Circle() functions of the matplotlb library; among them, the figure() function is used to determine the canvas size, and the Circle() function is used to configure the relevant information of the circle, and then draw round.
The operating environment of this tutorial: Windows 7 system, Python 3 version, Dell G3 computer.
python circle drawing code
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()
The above is the detailed content of What function is used to draw a circle in Python?. For more information, please follow other related articles on the PHP Chinese website!