python通过matplotlib⽣成复合饼图
可以通过matplotlib实现
s青春韶华 importConnectionPatch
#制画布fig=(figsize=(9,5.0625))
ax1=_subplo挨揍 t(121)
ax2=_subplot(122)
ts_adjust(wspace=0)
#⼤饼图的制作
labels=
size=ty
explode=(0,0,0,0,0,0.1)
(size,autopct='%1.1f%%',startangle=30,labels=labels,explode=explode)
#⼩饼图的制作
labels2=
size2=ty
width=0.2
(size2,autopct='%1.1f%%',startangle=90,labels=labels2,
radius=0.5,shadow=True)
#使⽤ConnectionPatch画出两个饼图的间连线
#先得到饼图边缘的数据
theta1,theta2=s[5].theta1,s[5].theta2
center,r=s[5].center,s[5].r
#画出上边缘的qq男生头像动漫 连线
x=r*(/180*theta2)+center[0]
y=(/180*theta2)+center[1]
con=ConnectionPatch(xyA=(-width/2,0.5),xyB=(x,y),
coordsA='data',coordsB='data',axesA=ax2,axesB=ax1)
_linewidth(2)
_color=([0,0,0])
_a生活老师 rtist(con)
#画出下边缘的连线
x=r*(/180*theta1)+center[0]
y=(/180*theta1)+center[1]
con=ConnectionPatch(xyA=(-width/2,-0.5),xyB=(x,y),
coordsA='data',coordsB='data',axesA=ax2,axesB=ax1)
_linewidth(2)
_color=([0,0,0古代故事大全 ])
_artist(con)
()
输出:
图源数据为快餐店销量
总结
以上所述是⼩编给⼤家介绍的python通过matplotlib实现⽣成复合饼图,希望对⼤家80plus认证 有所帮助!
本文发布于:2023-03-18 11:52:46,感谢您对本站的认可!
本文链接:https://www.wtabcd.cn/zhishi/a/1679111566147791.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文word下载地址:复合饼图怎么制作.doc
本文 PDF 下载地址:复合饼图怎么制作.pdf
留言与评论(共有 0 条评论) |