-
-
Notifications
You must be signed in to change notification settings - Fork 18.1k
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
Plot PeriodIndex data with steps #11862
Comments
My initial thoughts are that this wouldn't be worth making an API breaking change, so I don't see the default changing to a different linestyle.
Not quite sure what you're saying here, sorry. But I think that sounds like more of an enhancement for matplotlib? As long as pandas gets the data to matplotlib in some format that it understands. FWIW, I would typically use something like |
Let me explain a bit further. I would say that using steps is maximally informative given Period data. For instance, say you have a table with a monthly period index. If January 2016 has value Matplotlib is only a plotting library/backend. As far as I understand, it doesn't know (and doesn't want to know) about data or types of data, only about canvases and coordinates, lines, shapes etc. on those canvases. I can understand that you don't want to break the API. I guess that in any case plotting is not the core business of Pandas. Perhaps, in the long run, it would be nice to build a completely separate package that focuses purely on interfacing DataFrames, in all their variety, with Matplotlib. |
All fair points. #8707 is adding a new Index type for representing intervals. I think the current plan is to rewrite |
Thanks for the issue, but it appears this hasn't gotten traction in a while so closing |
I would find it more natural for PeriodIndexed data to be plotted by default as a stepped line. A step better conveys the fact that the y-value one is plotting corresponds to that entire x-region, whereas a (linearly or otherwise) interpolated line suggests that one is using Timestamped data (since it suggests that the y-value is different at each point in time, which for periods is impossible to know).
It is, of course, possible to do this manually with
drawstyle=steps
, but this has the annoying problem that one of the Period "bins" will be missing (the one at the end).steps-mid
is ugly, since it cuts off half of the steps at both edges.It would be nice if the default would be changed to this
drawstyle
, but it would be even better if this style would be extended some way to fully handle Periods. Ideally, each Period step would be plotted between the edges of the Period and irregular Periods would be supported as well.The text was updated successfully, but these errors were encountered: