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

jointplot with kind="hex" fails with datetime64[ns] #3664

Open
fynnkroeger opened this issue Mar 25, 2024 · 0 comments
Open

jointplot with kind="hex" fails with datetime64[ns] #3664

fynnkroeger opened this issue Mar 25, 2024 · 0 comments

Comments

@fynnkroeger
Copy link

Minimal example:

import seaborn as sns
import numpy as np
dates = np.array(["2023-01-01", "2023-01-02", "2023-01-03"], dtype="datetime64[ns]")
sns.jointplot(x=dates, y=[1, 2, 3], kind="hex")

Error:

Traceback (most recent call last):
  File "/.../seaborn_bug.py", line 21, in <module>
    sns.jointplot(x=dates, y=[1, 2, 3], kind="hex")
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/seaborn/axisgrid.py", line 2307, in jointplot
    x_bins = min(_freedman_diaconis_bins(grid.x), 50)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/seaborn/distributions.py", line 2381, in _freedman_diaconis_bins
    iqr = np.subtract.reduce(np.nanpercentile(a, [75, 25]))
TypeError: the resolved dtypes are not compatible with subtract.reduce. Resolved (dtype('<M8[ns]'), dtype('<M8[ns]'), dtype('<m8[ns]'))

I think this should work, as datetime64[ns] is the default type for datetimes in pandas. It works when I omit kind="hex" or use kind="kde". The error was in version 0.13.2. In 0.11.2 I got a error in the same cases but it was a integer overflow with numpy during conversions.

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

No branches or pull requests

1 participant