国产探花免费观看_亚洲丰满少妇自慰呻吟_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ā)表
主站蜘蛛池模板: 固镇县| 新昌县| 永靖县| 罗甸县| 蒲城县| 镇赉县| 宜都市| 伊通| 濮阳市| 海林市| 九寨沟县| 台南县| 微博| 时尚| 南涧| 平乐县| 巴东县| 上蔡县| 九龙城区| 康马县| 响水县| 隆子县| 林甸县| 郯城县| 平湖市| 鄂托克旗| 顺昌县| 竹山县| 陈巴尔虎旗| 酉阳| 嘉峪关市| 乐业县| 上虞市| 玉溪市| 重庆市| 十堰市| 利津县| 剑河县| 南部县| 五莲县| 蚌埠市|