The Wayback Machine - https://web.archive.org/web/20240110183340/https://github.com/matplotlib/matplotlib/issues/27559
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]: Axes.pcolorfast() not working with datetime #27559

Closed
AndyXi163 opened this issue Dec 22, 2023 · 1 comment
Closed

[Bug]: Axes.pcolorfast() not working with datetime #27559

AndyXi163 opened this issue Dec 22, 2023 · 1 comment

Comments

@AndyXi163
Copy link

Bug summary

As of Dec. 11 2023, Axes.pcolorfast() seems to not work with datetime; see #27450 for more details.

Code for reproduction

import numpy as np
import matplotlib.pyplot as plt
import matplotlib.dates as dt
import matplotlib as mpl
import datetime

np.random.seed(19680801)


'''
Directly inputting datetime.datetime without processing them seems to generate compile errors for pcolorfast().
I have used date2num() to ensure that the graph prints correctly despite that such operations may defy the purpose of conducting such tests.
'''
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,seconds=0)) for i in range(10)]
dates_y = [(basedate_y + datetime.timedelta(days=1*i, hours=8*i, minutes=30*i,seconds=0)) for i in range(10)]
data = np.random.rand(0, 100)


fig, ax = plt.subplots()

pc = ax.pcolorfast(dates_x, dates_y, data)

ax.set_xlabel('Sample datetime')
ax.set_ylabel('Sample data')
ax.set_title('Sample test case for pcolorfast()')

plt.show()

Actual outcome

Traceback (most recent call last):
File "personal directory omitted", line 23, in
pc = ax.pcolorfast(dates_x, dates_y, data)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\andyx\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\matplotlib_init_.py", line 1478, in inner
return func(ax, *map(sanitize_sequence, args), **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\andyx\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\matplotlib\axes_axes.py", line 6501, in pcolorfast
self.update_datalim(np.array([[xl, yb], [xr, yt]]))
File "C:\Users\andyx\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\matplotlib\axes_base.py", line 2510, 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

It has been assumed that a graph should be produced similar to the one below, but with actual datetime as axes:
pcolorfast_plot

Additional information

This is part of a test case for issue #26864 ; same issue has been met when the same code is ran on matplotlib ver 3.7.1 on Google Colab.

Operating system

Windows 10

Matplotlib Version

3.8.2

Matplotlib Backend

No response

Python version

3.11.7

Jupyter version

No response

Installation

pip

@AndyXi163 AndyXi163 changed the title [Bug]: [Bug]: Axes.pcolorfast() not working with datetime Dec 22, 2023
@AndyXi163 AndyXi163 changed the title [Bug]: Axes.pcolorfast() not working with datetime [Bug]: Axes.pcolorfast() not working with datetime Dec 22, 2023
@AndyXi163 AndyXi163 closed this as not planned Won't fix, can't repro, duplicate, stale Dec 23, 2023
@rcomer
Copy link
Member

rcomer commented Dec 23, 2023

xref #27526

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

2 participants