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

pcolormesh x-axis with datetime broken for nearest shading #18547

Closed
Milestone
@fthyssen

Description

@fthyssen

Bug report

Bug summary

When using a datetime x-axis in a pcolormesh, and nearest shading,

TypeError: '>=' not supported between instances of 'datetime.timedelta' and 'int'

is raised.

From what I can tell,#18398 assumed comparison with 0 would always be possible, but this isn't the case fordatetime.timedelta.

Code for reproduction

fromdatetimeimportdatetimefrommatplotlibimportpyplotaspltx_coords= [datetime.fromtimestamp(x*3600)forxinrange(24)]y_coords= [*range(0,10)]plt.pcolormesh(x_coords,y_coords, [[*range(24)]for_inrange(10)],shading="nearest")

Actual outcome

Traceback (most recent call last):  File "<stdin>", line 1, in <module>  File ".local/lib/python3.8/site-packages/matplotlib/pyplot.py", line 2801, in pcolormesh    __ret = gca().pcolormesh(  File ".local/lib/python3.8/site-packages/matplotlib/__init__.py", line 1438, in inner    return func(ax, *map(sanitize_sequence, args), **kwargs)  File ".local/lib/python3.8/site-packages/matplotlib/axes/_axes.py", line 6093, in pcolormesh    X, Y, C, shading = self._pcolorargs('pcolormesh', *args,  File ".local/lib/python3.8/site-packages/matplotlib/axes/_axes.py", line 5651, in _pcolorargs    X = _interp_grid(X)  File ".local/lib/python3.8/site-packages/matplotlib/axes/_axes.py", line 5633, in _interp_grid    if not (np.all(dX >= 0) or np.all(dX <= 0)):TypeError: '>=' not supported between instances of 'datetime.timedelta' and 'int'

Expected outcome

None

Matplotlib version

  • Matplotlib version: 3.3.2
  • Python version: 3.8

works withpip3 install matplotlib==3.3.1, fails withpip3 install matplotlib==3.3.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp