首页 > 解决方案 > Seaborn 子图 x 轴未正确显示

问题描述

我使用 seaborn 创建了子图,但我的 x 轴显示不正确。岁月不顺?为什么是这样?

这是我的代码和输出:

g=sns.relplot(x="Year", y="Indicator_Value",
           data=Emissions_R_df,
           kind="line",
           style="Indicator_Name",
           hue="Indicator_Name",
           row="Country_Name"
           )
g.fig.suptitle("Amount of Emissions from CO2, CH4, N20, and others - 1960-2014", y=1.05)
g.set(xlabel="Years",
     ylabel="Emissions, kiloton(kt)")
g.fig.set_size_inches(15,20)
plt.gca().xaxis.set_major_locator(MaxNLocator(steps=[10]))
plt.show()

在此处输入图像描述

标签: python-3.xpandasmatplotlibseaborn

解决方案


推荐阅读