因此,我打算将给定数据集中性别之间的教育差异可视化。 我按性别对员工进行分组,并用此代码对他们的years_in_education进行汇总
df1 = df[["gender","years_in_education"]] #creating a sub-dataframe with only the columns of gender and hourly wage
staff4=df1.groupby(['gender']).sum() #grouping the data frame by gender and assigning it to a new variable 'staff4'
staff4.head() #creating a visual of the grouped data for inspection
然后我使用条形图绘制这段代码的差异>>
my_plot = staff4.T.plot(kind='bar',title="Education difference between Genders") #creating the parameters to plot the graph
图形显示为>>
但是我发现y轴的比例太高了,因为该数据中的最高就业年份是30。我打算将比例调整为0到30。我使用my_plot.set_ylim([0,30])
结果是>>
此图不反映第一个所示的数据。我该怎么做才能改变呢?
有什么想法吗?我还如何更改标签在y轴上的方向。