How to realize Circle drawing with Python
This article mainly introduces "how to achieve circle rendering with Python". In daily operation, I believe many people have doubts about how to achieve circle drawing with Python. The editor consulted all kinds of data and sorted out simple and easy-to-use operation methods. I hope it will be helpful for you to answer the doubts about "how to achieve circle drawing with Python". Next, please follow the editor to study!
The specific implementation code is as follows:
#-*-coding:utf-8-*-
#! python3
Importnumpyasnp
Importmatplotlib.pyplotasplt
# = =
# basic information of circles
# 1. Circle radius
Renew2.0
# 2. Central coordinate
A ~ b = (0). 0.)
# = =
# method 1: parametric equation
= NP. Arange (0pyrnp.pijin0.01)
Xantha r NP. Cos ()
Yawb r * NP. Sin ()
Figure = plt.figure ()
Axes=fig.add_subplot (111)
Axes.plot (XBI y)
Axes.axis ('equal')
Plt.title ('www.jb51.net')
# = =
# method 2: standard equation
X=np.arange (a Murray, a r, 0.01)
Yamazb np.sqrt (ruminant 2-(xmura) * * 2)
Figure = plt.figure ()
Axes=fig.add_subplot (111)
Axes.plot (XBI y) # the first half
The lower half of the axis. Draw (xmam mury) #
Plt.axis ('equal')
Plt.title ('www.jb51.net')
# = =
The running effect of plt.show ():
.
At this point, the study of "how to draw a circle with Python" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!