使用这个例子http://matplotlib.org/examples/pie_and_polar_charts/pie_demo_features.html 我怎么能在这个饼图中添加一个图例?我的问题是我有一个大切片 88.4%,第二大切片是 10.6%,其他切片是 0.7 和 0.3%。饼图周围的标签不会出现(最大切片除外),较小切片的百分比值也不会出现。所以我想我可以添加一个显示名称和值的图例。但是我还没发现怎么...
# -*- coding: UTF-8 -*-
import matplotlib.pyplot as plt
# The slices will be ordered and plotted counter-clockwise.
labels = 'Rayos X', 'RMN en solución', 'Microscopía electrónica', 'Otros'
sizes = [88.4, 10.6, 0.7, 0.3]
colors = ['yellowgreen', 'gold', 'lightskyblue', 'lightcoral']
explode = (0.1, 0, 0, 0)
plt.pie(sizes, explode=explode, labels=labels, colors=colors, shadow=True, startangle=90)
plt.legend(title="técnica")
# Set aspect ratio to be equal so that pie is drawn as a circle.
plt.axis('equal')
plt.show()