On 09/04/2012 10:36 PM, Paul Hobson wrote:
> import numpy as np
> import pandas
> import matplotlib.pyplot as plt
>
> # fake data
> x = np.random.normal(size=(20,))
> y = np.random.normal(size=(7,))
>
> # data frames
> xdf = pandas.DataFrame(x)
> ydf = pandas.DataFrame(y)
>
> # plot x data, get an MPL axes object
> ax = xdf.plot()
>
> # plot y data, using the axes already created
> ydf.plot(ax=ax)
>
>
>
> plt.show()
Paul,
your suggestion plots the two data series into the same plot frame, but the two series have different x axis limits:
the shortest ends at 7, the longest ends at 20.
My case is different, the two series have the same x axis limits (both have the same start time and the same end time)
but different sampling frequency: in the general case, the second series has N (integer) samples for each samples of
the first one. So each packet of N samples of the second series has the same time of the corresponding sample in the
first series.
I know that using df.reset_index(), df2 can be changed from multi index with time and col name, to a single level
numeric index having a double sampling frequency with respect to df1.
At this point, I have two series,
df1 with M samples starting from time T1 and ending at time T2, with a date index,
df2 with 2xM samples starting from time T1 and ending at time T2, with a numeric index.
I wish to plot df1 in one subplot with x axis ranging from T1 to T2 and to plot df2 into another subplot with the
same time axis of df1.