matplotlib.pyplot dataframe画图调节大小

错解

plt.figure(figsize=(20,10)
boy = stu_info.籍贯[stu_info.性别=='男'].value_counts()
girl = stu_info.籍贯[stu_info.性别=='女'].value_counts()
df_sex =pd.DataFrame({'男':boy,'女':girl})
df_sex.plot(kind='bar',stacked = True)

正解

boy = stu_info.籍贯[stu_info.性别=='男'].value_counts()
girl = stu_info.籍贯[stu_info.性别=='女'].value_counts()
df_sex =pd.DataFrame({'男':boy,'女':girl})
df_sex.plot(kind='bar',stacked = True,figsize=(20,10))

总结:其实就是调节参数,初学者总容易犯错,pyplot中的函数参数都太多了,所以找的时候容易失去耐心
df.plot()参数设置详解

你可能感兴趣的:(机器学习与数据分析)