Python 将seaborn barplot与matplotlib.plot()相结合

Python 将seaborn barplot与matplotlib.plot()相结合,python,matplotlib,seaborn,Python,Matplotlib,Seaborn,我正在尝试向sns.barplot添加一个绘图。 当我添加plt.plot时,它似乎把轴弄乱了 plt.figure(figsize=(15, 7)) _, labels = plt.xticks() plt.setp(labels, rotation=90) g = sns.barplot( IND.index, IND.NID_NGDP, color = sns.color_palette("Set1", 10)[3]) g = sns.barplot(IND.index, IND.NGS

我正在尝试向sns.barplot添加一个绘图。 当我添加plt.plot时,它似乎把轴弄乱了

plt.figure(figsize=(15, 7))
_, labels = plt.xticks()
plt.setp(labels, rotation=90)

g = sns.barplot( IND.index, IND.NID_NGDP, color = sns.color_palette("Set1", 10)[3])
g = sns.barplot(IND.index, IND.NGSD_NGDP, color = sns.color_palette("Set1", 10)[1])
g.set_ylabel('% of GDP')

ax2 = g.twinx()
#ax2.set_ylabel('% CA balance',color='b')
ax2.plot(IND.index,IND.BCA_NGDPD,label='CA Deficit (right axis)')
这给了我以下图表:

我想要这样的东西,上面画着IND.BCA\u NGDPD的线


啊!!很抱歉我只需要将最后一行更改为:

ax2.plot(g.get_xticks(),IND.BCA_NGDPD,label='CA Deficit (right axis)') 

不要介意!固定的我只需要:ax2.plotg.get_xticks,IND.BCA_NGDPD,label='CA右轴'