Home > Software engineering >  How to display a history chart for multiple symbols with yahoo query?
How to display a history chart for multiple symbols with yahoo query?

Time:10-23

What is the command to display the chart in lineplots

Incidentally, if you want to compare both stocks, it may make more sense to plot the percentages. E.g.:

df_pivot_perc = df_pivot.div(df_pivot.iloc[0,:]).mul(100)
fig, ax = plt.subplots(figsize=(10,6))

ax = sns.lineplot(data=df_pivot_perc, palette=['r','b'], dashes=False)
ax.xaxis.set_major_locator(md.WeekdayLocator(byweekday = 1))
ax.set_xlim(df_pivot.index.min(), df_pivot.index.max())

fmt = '%.0f%%'
yticks = mtick.FormatStrFormatter(fmt)
ax.yaxis.set_major_formatter(yticks)
ax.yaxis.set_major_locator(mtick.MultipleLocator(10))

plt.xticks(rotation=90)
plt.tight_layout()
plt.show()

Result:

lineplots percentages

  • Related