在饼图中添加图例后,我收到了一个UserWarning:
UserWarning: Legend does not support '47036560' instances.
A proxy artist may be used instead.
我想添加图例以显示我的csv文件中使用的内存状态和可用内存。
csv文件:
USED;FREE
26932440;47036560
我的代码:
import matplotlib.pyplot as plt
import numpy as np
plt.rcParams['text.color'] = 'k'
data = np.loadtxt('show-flash.csv' ,dtype=bytes, delimiter=';', usecols=(0, 1)).astype(str)
slice = data[1]
labels = data[0]
colors = ['lightskyblue', 'lightcoral']
explode = [0.05, 0]
plt.pie(slice, labels=labels, colors=colors, explode=explode, startangle=90, shadow=True, autopct='%1.1f%%')
plt.title('Show Flash\n(Bytes)')
plt.legend(slice,labels)
plt.show()