可以通过matplotlib实现
从matplotlib。补丁进口ConnectionPatch #制画布无花果=plt.figure (figsize=5.0625(9日)) ax?=fig.add_subplot (121) ax2=fig.add_subplot (122) fig.subplots_adjust (wspace=0) #大饼图的制作 标签=newdata8.index 大?newdata8.quantity 爆炸=(0,0,0,0,0,0.1) ax?。派(大小、autopct=% 1.1 f % %, startangle=30,标签=标签,爆炸=爆炸) #小饼图的制作 labels2=others.index size2=others.quantity 宽=0.2 ax2。派(size2 autopct=% 1.1 f % %, startangle=90,标签=labels2, 半径=0.5,影子=True) #使用ConnectionPatch画出两个饼图的间连线 #先得到饼图边缘的数据 θ?,θ=ax1.patches [5]。θ?,ax1.patches [5] .theta2 中心,r=ax1.patches [5] .center, ax1.patches [5] r #画出上边缘的连线 x=r * np.cos (np.pi/180 *θ)+中心[0] y=np.sin (np.pi/180 *θ)+中心[1] 反对=ConnectionPatch (xyA=(0.5 - width/2,), xyB=(x, y), coordsA=荨?coordsB=荨?axesA=ax2 axesB=ax?) con.set_linewidth (2) con.set_color=((0, 0, 0)) ax2.add_artist (con) #画出下边缘的连线 x=r * np.cos (np.pi/180 *θ?)+中心[0] y=np.sin (np.pi/180 *θ?)+中心[1] 反对=ConnectionPatch (xyA=(-0.5 - width/2,), xyB=(x, y), coordsA=荨?coordsB=荨?axesA=ax2 axesB=ax?) con.set_linewidth (2) con.set_color=((0, 0, 0)) ax2.add_artist (con)
plt.show ()
输出: