May-16-2022, 06:48 PM
This programs works fine:
If I uncomment L7, I get the secondary axis label ALONG WITH overlapping, y-axis labels from 0.0 to 1.0. What causes that and how do I remove those?
Thanks!
import matplotlib.pyplot as plt sample_data = [[3000,18], [3200,17], [3500,16], [4000,12]] sample_df = pd.DataFrame(sample_data, columns = ['SPX', 'Spread_Price']) fig, axs = plt.subplots(2,1) axs[0].set_ylabel('Spread Price') #axs[0].twinx().set_ylabel('SPX Price') #why does this add 0.0 to 1.0 axis labels AND overlap text?xs[0].plot(sample_df['Spread_Price'],color='red') axs[0].twinx().plot(sample_df['SPX']) #twinx will always be the R axis. axs[1].twinx().plot(sample_df['Spread_Price']) #need .twinx() as an attribute, and .plot is a method of that. axs[1].plot(sample_df['SPX'],color='red') #axs[0].twinx().set_yticklabels([]) plt.tight_layout() plt.show()The only problem is I don't have a secondary axis label.
If I uncomment L7, I get the secondary axis label ALONG WITH overlapping, y-axis labels from 0.0 to 1.0. What causes that and how do I remove those?
Thanks!