I really like the "explode" option on matplotlib pie charts. I was hoping to be able to "explode in groups". I'm plotting lots of little slices that fall into 3 or 4 categories. I'd like to explode all the little slices together, as groups.
# Data is in this format:
axis1
Unix A 3
B 1
D 1
Window C 30
Apple A 1
D 12
Linux A 10
C 20
fig, ax = plt.subplots()
ax.set_aspect('equal')
labels=["{0} {1}".format(l1, l2) for l1, l2 in data.index]
wedges, texts, percs = ax.pie(data, labels= labels , autopct= '%1.1f%%',shadow=True, radius=3) #lambda p:f'{p:.2f}%' if p > 10 else '')
ax.axes.get_yaxis().set_visible(False)
I've tried:
groups = ["{0}".format(l1, l2) for l1, l2 in data.index]
for i in groups:
ang = np.deg2rad((wedges[i[-1]].theta2 + wedges[i[0]].theta2)/2)
But I'm getting the following error:
"list indices must be integers or slices, not str"
.
The desired result would look something like this: