I am plotting a pandas DataFrame with several columns as below:
fig, ax = py.subplots(figsize=(11.7, 8.3))
df.plot(ax=ax, secondary_y=[A])
I can format the primary yaxis with a command as below:
ax.yaxis.set_major_formatter(FormatStrFormatter('%d days'))
How can I apply formatting to the secondary Y-axis (the one that displays on the right)?
You can access the secondary ax with ax.right_ax
. See the pandas docs on this: Plotting on a secondary y-axis.
So you can do like this:
ax.right_ax.yaxis.set_major_formatter(FormatStrFormatter('%d days'))
Using matplotlib, you can also access it as ax.twinx()