
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,感謝您對本站的認可!
本文鏈接:http://www.newhan.cn/zhishi/a/1679111566147791.html
版權聲明:本站內容均來自互聯網,僅供演示用,請勿用于商業和其他非法用途。如果侵犯了您的權益請與我們聯系,我們將在24小時內刪除。
本文word下載地址:復合餅圖怎么制作.doc
本文 PDF 下載地址:復合餅圖怎么制作.pdf
| 留言與評論(共有 0 條評論) |