Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
Description
Problem
As noted during the review of#27114, the current support of units in stackplot is subpar, particularly for they
axis.
For datetimes in particular, the implicit 0 of the API is problematic, introducing 1970-01-01 when that is not a relevant date.
Therefore I suggest allowingbaseline
to be not only the current supported string literals, but also a scalar value (or potentially an array, I guess) such that a "sensible" baseline can be provided for cases where0
is not sensible. (even the other options for baseline assume you want your plot centered around 0... I'm not concerned about wanting "wiggle centered at 2023-02-28" or anything like that, that seems perhaps a bridge too far.)
I also think it is important to explicitly state that the y values are in delta units (similar to how we do for e.g.bar
for thewidth
parameter. This is already true in that adding actual datetime values will fail, but passing timedelta objects will work.
Finally, thecumsum
call contains apromote_types(y.dtype, np.float32)
, which will fail fornp.timedelta64
arrays (Edit, to be consistent with other points, clarified that I really meant timedelta instead of datetime64 here):
stack=np.cumsum(y,axis=0,dtype=np.promote_types(y.dtype,np.float32)) |
So either removing that or at least handling the error case is needed. It's not fully clear to me what we are guarding against there, ascumsum
of integers is fine being integral, though I guess wecould run into overflow issues? Passingdatetime.timedelta
asobject
arrays (or as lists which get turned intoobject
arrays) will work and producea plot, just without a sensible baseline, currently.
Proposed solution
No response