May-16-2022, 08:15 PM
(This post was last modified: May-16-2022, 08:15 PM by deanhystad.)
twinx() is a function that creates an additional axis. Each time you call it it makes a new axis. In the working code twinx() is called once, to create one additional axis. You called twinx() multiple times on the same plot. This poor plot has 3 y axis
axs[0].twinx().set_ylabel('SPX Price') # This creates a new axis (#2) axs[0].plot(sample_df['Spread_Price'],color='red') axs[0].twinx().plot(sample_df['SPX']) # This creates an additional axis (#3), not the same as above