Tôi không biết về bất kỳ cách trực tiếp để xác định bánh phát nổ nhóm, nhưng nó là khá đơn giản để sử dụng bản vá lỗi để vẽ lại một chiếc bánh với các nhóm như
# 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)
Điều này có thể dẫn đến âm mưu như
Tất nhiên, bạn có thể tính toán góc theta yêu cầu dựa trên dữ liệu của bạn thay vì sử dụng dữ liệu được xác định trước.