The Wayback Machine - https://web.archive.org/web/20240106174012/https://github.com/matplotlib/matplotlib/issues/27526
Skip to content
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

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

Open
QuLogic opened this issue Dec 16, 2023 · 0 comments
Open

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

QuLogic opened this issue Dec 16, 2023 · 0 comments

Comments

@QuLogic
Copy link
Member

QuLogic commented Dec 16, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant