# -*- coding: utf-8 -*-
# @Time : 2022/5/5 11:01
# @Author : Sunli
import csv
import matplotlib.pyplot as plt
import pandas as pd
plt.rcParams['font.sans-serif'] = ['SimHei']
plt.rcParams['font.family'] = 'sans-serif'
plt.rcParams['axes.unicode_minus'] = False
data = pd.read_csv('D:/Fall_dataset/MobiAct_Dataset_v2.0/counts/data/test_counts.csv',encoding='GB2312')
xdata = []
y1data = []
# y2data = []
xdata = data.loc[:, 'label']
ydata = data.loc[:, 'counts']
# y2data = data.loc[:, '列名3']
print(xdata)
print(ydata)
#plt.plot(xdata, ydata, color='r', marker='o', mec='r', mfc='w', label=u'label')
# plt.plot(xdata, y2data, color='b', marker='o', mec='r', mfc='w', label=u'列名3') # color可自定义折线颜色,marker可自定义点形状,label为折线标注
plt.pie(ydata, labels=xdata, autopct='%1.1f%%') # 绘制饼图
plt.title('训练集不同行为数量对比')
#plt.title(u"表名", size=10)
# plt.legend()
# plt.xlabel(u'x轴名', size=10)
# plt.ylabel(u'y轴名', size=10)
plt.show()
|