国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > Python > 正文

python通過matplotlib生成復(fù)合餅圖

2020-02-15 21:22:18
字體:
供稿:網(wǎng)友

可以通過matplotlib實現(xiàn)

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.indexsize = newdata8.quantityexplode=(0,0,0,0,0,0.1)ax1.pie(size, autopct='%1.1f%%',startangle=30,labels=labels,explode=explode)#小餅圖的制作labels2 = others.indexsize2 = others.quantitywidth=0.2ax2.pie(size2, autopct='%1.1f%%',startangle=90,labels=labels2,    radius=0.5,shadow=True)#使用ConnectionPatch畫出兩個餅圖的間連線#先得到餅圖邊緣的數(shù)據(jù)theta1, theta2 = ax1.patches[5].theta1, ax1.patches[5].theta2center, 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()

輸出:

圖源數(shù)據(jù)為快餐店銷量

總結(jié)

以上所述是小編給大家介紹的python通過matplotlib實現(xiàn)生成復(fù)合餅圖,希望對大家有所幫助!

發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 武鸣县| 大冶市| 林甸县| 简阳市| 永登县| 马边| 华坪县| 邵东县| 河北区| 汤阴县| 石阡县| 蕉岭县| 石首市| 玉林市| 巩义市| 弥渡县| 凌云县| 宜宾县| 岢岚县| 鹤岗市| 沙坪坝区| 孟村| 漠河县| 贵德县| 上犹县| 康定县| 东安县| 临颍县| 稻城县| 津市市| 金山区| 林周县| 来凤县| 桓仁| 鲜城| 莫力| 南溪县| 蓝田县| 泸溪县| 夏津县| 湖州市|