-
-
Notifications
You must be signed in to change notification settings - Fork 19.3k
Description
-
I have checked that this issue has not already been reported.
-
I have confirmed this bug exists on the latest version of pandas.
-
(optional) I have confirmed this bug exists on the master branch of pandas.
I have two datasets from different sources. They span more or less the same time, contain different data, sampled at different rate.
I am trying to plot these on two subplots with a shared x axis.
Making sample data:
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
time1 = pd.date_range(
'2020-11-08T09:31:06', '2020-12-01T22:59:59', freq='S', tz='UTC'
)
df1 = pd.DataFrame(
np.sin(2 * np.pi * 1e-5 * np.arange(time1.size)),
index=time1,
columns=['x1']
)
time2 = pd.date_range(
'2020-11-08T09:32:00', '2020-12-01T22:58:00', freq='D', tz='UTC'
)
df2 = pd.DataFrame(
np.sin(2 * np.pi * 1e-1 * np.arange(time2.size)),
index=time2,
columns=['x2']
)Minimal plotting example:
fig, (ax1, ax2) = plt.subplots(2, sharex=True)
fig.subplots_adjust(0, 0, 1, 1, hspace=0.15)
df1.x1.plot(ax=ax1, legend=False)
df2.x2.plot(ax=ax2, legend=False)I get OverflowError and a very long traceback but I think the problem is how the sharex=True is handled. When I set sharex=False, the error goes away and it plots fine but unaligned.
Output of pd.show_versions()
I get ImportError: Can't determine version for pip
But:
Pandas: 1.2.3
Matplotlib: 3.3.2
[paste the output of pd.show_versions() here leaving a blank line after the details tag]