Skip to content

[Bug]: pcolorfast does not support units for X/Y #27526

Open
@QuLogic

Description

@QuLogic

Bug summary

As found in #27450, the X/Y arguments to pcolorfast do not support units.

Code for reproduction

import datetime

import numpy as np
import matplotlib.pyplot as plt


np.random.seed(19680801)

basedate_x = datetime.datetime(2023, 12, 6, 1, 30, 30)
basedate_y = datetime.datetime(2024, 5, 5, 12, 15, 45)
dates_x = [basedate_x + datetime.timedelta(days=1*i, hours=6*i, minutes=20*i)
           for i in range(10)]
dates_y = [basedate_y + datetime.timedelta(days=1*i, hours=8*i, minutes=30*i)
           for i in range(10)]

data = np.random.rand(0, 100)

fig, ax = plt.subplots()
pc = ax.pcolorfast(dates_x, dates_y, data)

Actual outcome

Traceback (most recent call last):
  File "/home/elliott/code/matplotlib/pcolorfast.py", line 19, in <module>
    pc = ax.pcolorfast(dates_x, dates_y, data)
  File "/home/elliott/code/matplotlib/lib/matplotlib/__init__.py", line 1472, in inner
    return func(
  File "/home/elliott/code/matplotlib/lib/matplotlib/axes/_axes.py", line 6527, in pcolorfast
    self.update_datalim(np.array([[xl, yb], [xr, yt]]))
  File "/home/elliott/code/matplotlib/lib/matplotlib/axes/_base.py", line 2503, in update_datalim
    if not np.any(np.isfinite(xys)):
TypeError: ufunc 'isfinite' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''

Expected outcome

A plot similar to pcolormesh, with dates on the x/y axis.

Additional information

No response

Operating system

No response

Matplotlib Version

589d3fb

Matplotlib Backend

No response

Python version

No response

Jupyter version

No response

Installation

git checkout

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