1、画布颜色
def drawn_fig( st, groupby_names , count_name,m,n):
st = st.groupby([ groupby_names ])[count_name].mean().reset_index()
#画布大小,外围颜色
plt.figure(figsize=(m,n),facecolor='white')
#stype ,背景色,鬼知道我找这一句找了多久...
plt.style.use('classic')
#网格
#plt.grid()
# 中文字体设置,不会到为啥我笔记本和台式matplotlib是一个版本,台式成功了,笔记本没有...
plt.rcParams['font.sans-serif'] = ['SimHei']
plt.rcParams['axes.unicode_minus'] = False
y_num = st[count_name]
#x_scale = range(st.shape[0]) # 重设 x 轴刻度值
#x_index = st[groupby_names].values # 重设 x 轴刻度值
#plt.bar(x_scale, y_num, width=1,edgecolor = 'white')
plt.plot( x_scale, y_num )
#plt.xticks(x_scale,x_index,rotation=0) # 重设 x 轴刻度值
# 子图的上下空白设定,我这儿只有一个图 用不到
#plt.subplots_adjust(top = 0, bottom = 0, right = 0, left = 0, hspace = 0, wspace = 0)
plt.xlabel(groupby_names)
plt.ylabel('Number of stores')
# save
#plt.savefig("city_store_nums.png")
drawn_fig(transactions , 'store_nbr', 'transactions',10,6)
2、待续