import matplotlib.pyplot as plt
fig=plt.figure(figsize=(15,10),facecolor=‘w’)
def plotCircle(x,y,radius,color,alphaval):
circle=plt.Circle((x,y),radius=radius,fc=color,
alpha=alphaval)
fig.gca().add_patch(circle)
nofcircle=plt.Circle((x,y),radius=radius,ec=color,fill=False)
fig.gca().add_patch(nofcircle)
x=[55,83,90,13,55,82,96,55,69,19,55,95,62,96,82,30,22,39,54,50,69,56,55,55,47,55,20,86,78,56]
y=[5,3,4,0,1,0,1,3,5,2,2,0,2,4,6,0,0,1,0,0,0,0,1,1,0,0,3,0,0,1,0]
r=[23,17,15,13,13,12,12,11,11,10,10,10,10,10,9,9,9,8,8,8,8,8,8,8,7,7,7,6,6,6]
for i in range(0,len(x)):
plotCircle(x[i],y[i],r[i],‘b’,0.1)
plt.axis(‘scaled’)
plt.show()
python数据可视化–Mastering python Data Visualization–【印度】科斯.拉曼著—程豪译–【M】北京:机械工业出版社
2021-01-30
最新推荐文章于 2022-05-05 20:43:26 发布
该博客展示了如何使用matplotlib库在Python中创建一个圆形分布图。代码示例中,定义了一个函数plotCircle用于绘制带填充和不带填充的圆,并在坐标系上应用了多个圆圈,通过调整半径、颜色和透明度来展示数据分布。最后,设置了坐标轴比例并显示了图形。
摘要由CSDN通过智能技术生成