Donate. I desperately need donations to survive due to my health

Get paid by answering surveys Click here

Click here to donate

Remote/Work from Home jobs

Shifted plots in combined axis plot in seaborn

I am trying to combine barplot and line plot in seaborn. However, the result which is shown below is that the line plot in shifted to the right and starts from '4' for no obvious reason (at least for me). The code I use is as follows:

fig, ax1 = plt.subplots(figsize = (10,8))
ax1 = sns.barplot(x = df['Month'],
                  y = df['M1'],
                  hue = df['Fabryka_MA'], 
                  ci=None)
ax1.legend_.remove()

ax2 = ax1.twinx()
ax2 = sns.lineplot(x = df['Month'], 
               y = df['M2'], 
               hue = df['Factory'], 
               ci = None, 
               legend = None)

ax2.grid(None)
plt.show()

enter image description here

Comments