Python 海伯恩线图。数据集中1945年前后的垂直线

Python 海伯恩线图。数据集中1945年前后的垂直线,python,seaborn,Python,Seaborn,在这个seaborn线形图中放置一条垂直线需要一些帮助。这条线应该把1945年前后的人口分开。该行还应在不移动数据的情况下保持当前图形的位置 以下是线条图的代码和图像 sns.lineplot(x="year", y="population", hue="region", data=japan_pop, ci=None) plt.title('Population', fontsize

在这个seaborn线形图中放置一条垂直线需要一些帮助。这条线应该把1945年前后的人口分开。该行还应在不移动数据的情况下保持当前图形的位置

以下是线条图的代码和图像

sns.lineplot(x="year", y="population",
             hue="region",
             data=japan_pop, ci=None)
plt.title('Population', fontsize=14)
plt.legend(bbox_to_anchor=(1.05, 1), loc=2, borderaxespad=0.)
plt.show()

您可以使用matplotlib的axvline方法:

plt.axvline(1945,0,max(japan_pop.population))

知道了!谢谢我想我试过了,但我想我错了