大家好,又見面了,我是你們的朋友全棧君。
python畫圓運用了matplotlb庫的figure()和Circle()函數;其中,figure()函數用於確定畫布大小,而Circle()函數用於配置圓的相關信息,進而畫圓。H9Z少兒編程網-https://www.pxcodes.com
H9Z少兒編程網-https://www.pxcodes.com
本教程操作環境:windows7系統、Python3版、Dell G3電腦。H9Z少兒編程網-https://www.pxcodes.com
python畫圓代碼H9Z少兒編程網-https://www.pxcodes.comfrom 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()
發布者:全棧程序員棧長,轉載請注明出處:https://javaforall.cn/129611.html原文鏈接:https://javaforall.cn