日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪(fǎng)問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 编程语言 > python >内容正文

python

python绘制饼图explode_python通过matplotlib生成复合饼图

發(fā)布時(shí)間:2025/3/15 python 32 豆豆
生活随笔 收集整理的這篇文章主要介紹了 python绘制饼图explode_python通过matplotlib生成复合饼图 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

可以通過(guò)matplotlib實(shí)現(xiàn)

from matplotlib.patches import ConnectionPatch

#制畫(huà)布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畫(huà)出兩個(gè)餅圖的間連線(xiàn)

#先得到餅圖邊緣的數(shù)據(jù)

theta1, theta2 = ax1.patches[5].theta1, ax1.patches[5].theta2

center, r = ax1.patches[5].center,ax1.patches[5].r

#畫(huà)出上邊緣的連線(xiàn)

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)

#畫(huà)出下邊緣的連線(xiàn)

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ù)為快餐店銷(xiāo)量

總結(jié)

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

時(shí)間: 2020-02-04

總結(jié)

以上是生活随笔為你收集整理的python绘制饼图explode_python通过matplotlib生成复合饼图的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。