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

What function is used to draw a circle in Python?

青灯夜游
Release: 2021-03-09 17:17:40
Original
3996 people have browsed it

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()
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template