2015-10-14 1 views
0

J'essaie d'ajouter un tracé à un sns.barplot. Il semble bousiller l'axe quand j'ajoute le plt.plot()Combinaison de barplot seaborn avec matplotlib.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)') 

Cela me donne le tableau suivant:

What I get

Je veux quelque chose comme ça avec la ligne IND .BCA_NGDPD dessiné à travers elle

What I hope to get .. plus a line

+0

Peu importe! Fixé. J'avais juste besoin de: ax2.plot (g.get_xticks(), IND.BCA_NGDPD, label = 'CA Deficit (axe droit)') –

Répondre

0

Ah! Désolé ... Je juste besoin de changer la dernière ligne à:

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