Home  >  Article  >  Backend Development  >  What function is used to draw a circle in Python?

What function is used to draw a circle in Python?

青灯夜游
青灯夜游Original
2021-03-09 17:16:343958browse

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.

What function is used to draw a circle in Python?

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()

What function is used to draw a circle in Python?

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn