-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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 DataFrame with TimedeltaIndex (x-axis) #799
Comments
+1 |
Does anyone have any suggestions on how the timedelta values should be labeled on the axes? Or some examples of how other plotting libraries handle this? |
it can be: hh:mm:ss.000000000 |
Timedelta values could be labeled on the axes the same manner than |
Maybe this Pandas issue about formatting Below 24h, Be also aware that the current way negative When events resolution is only millisecond, we probably don't need to display Timestamp with microsecond or nanosecond resolution. |
Any update on this? I'm using plotly express to look at histograms of TimeDelta objects and the X-axis labeling is basically useless. I have to manually convert to hours, minutes, etc. |
If your organization has a software budget and needs this feature, you can prioritize & sponsor the development of it by reaching out to our team: https://plot.ly/products/consulting-and-oem/. Much of our development is funded this way. Otherwise, we'll update this issue when it's planned for an upcoming release. There are no updates at this moment and it is still a good idea. |
I've tried to fix this in different ways within my scratch plotly.py space but it always comes down to how Timedelta wants to be treated in plotly.js as a numeric entity and not as a weird date or string value. What's happening now when using a Timedelta series or index, the underlying data representations are getting written out as raw numerical values and the time unit information is lost. The values just show up in plotly.js as numbers. With extra work, you can cause the timedeltas to be printed out as strings, but then you lose the niceness of a numerical graph (interpolation, scaling, etc). What would be really nice would be to let timedeltas write themselves out numerically much like they already are, let that numeric value get passed around like it already is but on the plotly.js side, it would be nice if we could have provided a Timedelta specific print format specifier. That way axis labels and hovers print in a timedelta iso format while still being expressed numerically underneath the covers. I'm suggesting all that's needed is a Timedelta specific print format specifier. Maybe something that uses %t and %T where the underlying units can be either assumed or tacked on as a modifier, "%t!s" as an idea. More format expression would be nice if possible, the more like date formatting the better if possible, but these are just quick ideas for syntax examples. There's just no way to use Timedelta as an axis cleanly without something like this. It either gets turned into weird datetimes or you have to turn them all into strings. If you only want the time and no days, you can still hack timedelta somewhat by turning them all into actual datetimes:
and then using a tick format specifier to print only the time portion:
Having said all of this, and already wished for more than just iso format, something even more flexible like embedded js or some client side callback might find even more uses: But that's pie in the sky dreaming. |
I'd like to see this, even if within plotly express they handle the change from the |
Hi, any update on this issue? |
I'm also looking forward for this issue to be resolved. In my case, I want to plot a gantt-chart-like bar plot, and in my case the x-axis goes from one time to another - which in a bar plot is given by a timedelta. edit: I have compared the html generated by
Now I have a decent range and tick labels on the x axis |
I also have this issue. I have some timeseries that are a few years long, but I would like the timeaxis as time since a specific date. It would also enable me to plot several timeseries together to compare, while these have different start dates in calendar time. The tick labels should be days or 10s of days or 100s of days. When I zoom in, it could switch to days+hh:mm:ss.xxxx. |
Hi @mhangaard |
Hello,
Plotly.py doesn't display x axis well when using a
TimedeltaIndex
When using
TimedeltaIndex
I getx-axis have odd values starting with
P0D 0H0M0.
but when using a
DatetimeIndex
I getIt will be great if Plotly.py could handle
TimedeltaIndex
without hassle.Kind regards
The text was updated successfully, but these errors were encountered: