我不知道有任何指定分组爆炸馅饼的直接方法,但是使用补丁来重新绘制像
# original part (left)
import numpy as np
import matplotlib.pyplot as plt
f,ax = plt.subplots(1,2)
ax[0].set_aspect('equal')
data=np.abs(np.random.randn(7))
wedges, texts = ax[0].pie(data)
# redraw plot using patches (right)
import matplotlib.patches as mpatches
from matplotlib.collections import PatchCollection
ax[1].set_aspect('equal')
ax[1].axis('off')
groups=[[0,1,2],[3,4],[5,6]]
radfraction = 0.1
patches = []
for i in groups:
ang = np.deg2rad((wedges[i[-1]].theta2 + wedges[i[0]].theta1)/2,)
for j in i:
we = wedges[j]
center = (radfraction*we.r*np.cos(ang), radfraction*we.r*np.sin(ang))
patches.append(mpatches.Wedge(center, we.r, we.theta1, we.theta2))
colors = np.linspace(0, 1, len(patches))
collection = PatchCollection(patches, cmap=plt.cm.hsv)
collection.set_array(np.array(colors))
ax[1].add_collection(collection)
ax[1].autoscale(True)
这可能会产生类似的情节
当然,您可以根据数据计算所需的θ角度,而不是使用预先计算的角度.