【发布时间】:2017-05-16 07:04:17
【问题描述】:
在饼图中添加图例后,我收到了 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()
【问题讨论】:
标签: python csv matplotlib