Issue
I'm trying to plot two series of different scales but I can't seem to figure out the second_y parameter. Code so far:
googletrends_df['Chipotle Mexican Grill: (United States)'].plot(figsize = (15,8), legend = True, second_y = googletrends_df['TOTAL ADSPEND'])
googletrends_df['TOTAL ADSPEND'].plot(legend = True);
But it doesn't seem to be plotting the second axis as seen below:
Solution
import matplotlib.pyplot as plt
Try:
ax=googletrends_df['Chipotle Mexican Grill: (United States)'].plot(legend=True)
googletrends_df['TOTAL ADSPEND'].plot(figsize=(15,8),secondary_y=True,ax=ax,legend=True)
plt.show()
Since you didn't provide your dataframe so I tested this on sample dataframe:
#sample dataframe
googletrends_df=pd.DataFrame(np.random.randn(6,2),columns=['Chipotle Mexican Grill: (United States)','TOTAL ADSPEND'])
Answered By - Anurag Dabas
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.