下面是一些与我实际操作类似的示例代码:
import matplotlib.pyplot as plt
x = ['a', 'b', 'c']
y = [1.1, 3.5, 2.2]
y1_sizes = y
y2_sizes = y
fig, axarr = plt.subplots(1, 2)
ax1 = axarr[0]
ax2 = axarr[1]
ax1.pie(y1_sizes, shadow=True, startangle=90, autopct='%1.1f%%')
ax1.axis('equal')
ax1.set_title('Old Stuff')
ax2.pie(y2_sizes, shadow=True, startangle=90, autopct='%1.1f%%')
ax2.axis('equal')
ax2.set_title('New Stuff')
lgd1 = ax1.legend(x, loc='lower center')
lgd2 = ax2.legend(x, loc='lower center')
fig.suptitle('My Chart Title', fontweight='bold')
这就是结果