I want to plot time-series on a double y-axis with matplotlib and rescale the axis so that the origin (y=0) is aligned for both axis.
I have looked at this question but the suggested solutions can cut some data out of the plot.
For example:
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
np.random.seed(1)
df = pd.DataFrame(np.random.randn(100, 3), columns=['A', 'B', 'C']).cumsum()
df['Total'] = df[['A', 'B', 'C']].sum(1)
fig, ax = plt.subplots(1)
df.drop('Total', axis=1).plot(ax=ax)
ax2 = ax.twinx()
df['Total'].plot(ax=ax2, color='k', linestyle='--')
Using @drevicko solution (from the link above), I obtain the chart below. The origin for the two axis is now aligned, but part of the green line is left out of the plot.
How can I align the origin and leave all data in the plot frame?