-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
(WIP) BUG/CLN: Better timeseries plotting / refactoring tsplot #7670
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@sinhrks status? |
@sinhrks status on this? |
@sinhrks status? |
@TomAugspurger can you pick this up for 0.15? or can defer to 0.15.1 |
Let me look at it today. |
This is an improvement (just a couple of fixups first). But still not entirely there. The following two plots should be identical I think: In [28]: import datetime
In [29]: pidx = pd.PeriodIndex(start='2010-01-01', freq='m', periods=5)
In [30]: didx = pd.DatetimeIndex(['2010-01-01', '2010-02-05', '2010-03-10', '2010-04-15', '2010-05-25'])
In [31]: x1 = pd.Series(np.arange(5), index=pidx)
In [32]: x2 = pd.Series(np.arange(5), index=didx)
In [33]: ax = x1.plot(marker='o')
In [34]: x2.plot(marker='^', ax=ax)
Out[34]: <matplotlib.axes._subplots.AxesSubplot at 0x11758ae80>
In [35]: ax.set_title("Period then DatetimeIndex")
Out[35]: <matplotlib.text.Text at 0x117b03160>
In [38]: plt.close()
In [39]: ax = x2.plot(marker='^')
In [40]: x1.plot(ax=ax, marker='o')
Out[40]: <matplotlib.axes._subplots.AxesSubplot at 0x117af5a58>
In [41]: ax.set_title("Datetime then PeriodIndex")
Out[41]: <matplotlib.text.Text at 0x117b88828> |
@TomAugspurger push? |
@TomAugspurger status? |
@TomAugspurger what are we oing with this (and #6608) ? |
Push I think. Right now it's only fixed in one direction iirc. |
@sinhrks, @TomAugspurger what is status on this? |
I'm revisiting this, and want to change
Let me confirm |
@TomAugspurger can you have a look |
Yeah, I'll see where we are at. |
I couldn't finish it yet because of the following (the same one as the @TomAugspurger pointed):
Based on the following code, there could be no single logic to revert converted https://github.com/pydata/pandas/blob/master/pandas/tseries/plotting.py#L78 Though this PR cannot cover all the issues, it can fix original one. Thus, one option is move this forward once leaving above as it is. |
@sinhrks status? |
I couldn't investigate the detail above yet. Would like to finish #9814 first which also has tsplot related changes. |
@sinhrks want to update |
Revisiting this... I believe we have to clarify the plotting rules first. This should cause current behavior changes.
Based on the rule, above @TomAugspurger 's example should result in latter(bottom) output in both cases. I've created a demo on Gist, but not able to cover all conditions yet. |
I think those all seem reasonable... |
@sinhrks @TomAugspurger status of this? |
@sinhrks status? |
status? |
1 similar comment
status? |
closing, but @sinhrks pls reopen if you want / can fix. |
Must be revisited after #7717.
#6608 seems to be solved by following 4 fixes.
PeriodIndex
should support the same freqs asDatetimeIndex
(Related to BUG: Series.plot() doesn't work with CustomBusinessDay frequency #7222, maybe solved by ENH: Cleanup backend for Offsets and Period #5148)tsplot
as much)x_compat
to theax
which already holdstsplot
lines,tsplot
lines must be redrawn onx_compat
coordinates.to_timestamp(how='e')
always revertPeriodIndex
back to originalDatetimeIndex
x_compat
lines, continuous plot should be drawn onx_compat
coordinates (current version already have a logic, but cannot work ifax
once havefreq
property).Other refactoring:
tsplot
LinePlot
flow (separated as CLN: Simplify LinePlot flow #7717)Result using current PR (modified #6608 a little to show legend).
One question is whether
tsplot
is categorized as public function? If so, I'll prepare separate func.