资讯

精准传达 • 有效沟通

从品牌网站建设到网络营销策划,从策略到执行的一站式服务

python通过matplotlib生成复合饼图-创新互联

可以通过matplotlib实现

创新互联服务项目包括鄞州网站建设、鄞州网站制作、鄞州网页制作以及鄞州网络营销策划等。多年来,我们专注于互联网行业,利用自身积累的技术优势、行业经验、深度合作伙伴关系等,向广大中小型企业、政府机构等提供互联网行业的解决方案,鄞州网站推广取得了明显的社会效益与经济效益。目前,我们服务的客户以成都为中心已经辐射到鄞州省份的部分城市,未来相信会继续扩大服务区域并继续获得客户的支持与信任!
from matplotlib.patches import ConnectionPatch
#制画布fig = plt.figure(figsize=(9,5.0625))
ax1 = fig.add_subplot(121)
ax2 = fig.add_subplot(122)
fig.subplots_adjust(wspace=0)
#大饼图的制作
labels = newdata8.index
size = newdata8.quantity
explode=(0,0,0,0,0,0.1)
ax1.pie(size, autopct='%1.1f%%',startangle=30,labels=labels,explode=explode)
#小饼图的制作
labels2 = others.index
size2 = others.quantity
width=0.2
ax2.pie(size2, autopct='%1.1f%%',startangle=90,labels=labels2,
    radius=0.5,shadow=True)
#使用ConnectionPatch画出两个饼图的间连线
#先得到饼图边缘的数据
theta1, theta2 = ax1.patches[5].theta1, ax1.patches[5].theta2
center, r = ax1.patches[5].center,ax1.patches[5].r
#画出上边缘的连线
x = r*np.cos(np.pi/180*theta2)+center[0]
y = np.sin(np.pi/180*theta2)+center[1]
con = ConnectionPatch(xyA=(-width/2,0.5),xyB=(x,y),
           coordsA='data', coordsB='data',axesA=ax2,axesB=ax1)
con.set_linewidth(2)
con.set_color=([0,0,0])
ax2.add_artist(con)
#画出下边缘的连线
x = r*np.cos(np.pi/180*theta1)+center[0]
y = np.sin(np.pi/180*theta1)+center[1]
con = ConnectionPatch(xyA=(-width/2,-0.5),xyB=(x,y),
           coordsA='data', coordsB='data',axesA=ax2,axesB=ax1)
con.set_linewidth(2)
con.set_color=([0,0,0])
ax2.add_artist(con)
plt.show()

网页名称:python通过matplotlib生成复合饼图-创新互联
新闻来源:http://cdkjz.cn/article/dcegps.html
多年建站经验

多一份参考,总有益处

联系快上网,免费获得专属《策划方案》及报价

咨询相关问题或预约面谈,可以通过以下方式与我们联系

大客户专线   成都:13518219792   座机:028-86922220