Closed
Description
In the following I took the extreme case where there is no overlap between the two indexes for illustration purposes. When there is some overlap there is still the same issue and the last plotted timeseries is dictating the xaxis range.
Here is the code, tested on pandas 0.13.1:
import numpy as np
import pandas as pd
import pandas.util.testing
import matplotlib.pyplot as plt
np.random.seed(0)
ts = pd.util.testing.makeTimeSeries()[:20]
tsIrregular = ts.drop(ts.index[[3,7,11,16]])
def myPlot(ts):
fig, axes = plt.subplots(1,2)
ax = axes[0]
ax.set_title('left series first')
ts[:5].plot(ax=ax, label='left series')
ts[6:].plot(style='or', ax=ax, label='right series')
ax.legend(loc='best')
ax = axes[1]
ax.set_title('right series first')
ts[6:].plot(style='or', ax=ax, label='right series')
ts[:5].plot(ax=ax, label='left series')
ax.legend(loc='best')
return axes
myPlot(ts)
myPlot(tsIrregular)
What you get for the regular timeseries case is what you expect, i.e. the order you plot timeseries doesn't matter and the xaxis range is the union of the two timeseries indexes:
but what you get for the irregular timeseries case is rather suprising:
There are easy work-arounds, like aligning the timeseries before plotting, but it feels like irregular timeseries shouldn't be second-class citizens compared to regular ones.