Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[ENH]: Better support for stackplot with units [particularly datetimes] #27129

Open
@ksunden

Description

@ksunden

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp