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

Test for datetime input on jointplot, code to pass test (#3664) #3742

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

athompson1991
Copy link

The initial error comes from the _freedman_diaconis_bins function, which I fixed with a straightforward check on data type. However, once the code got through that hurdle, it runs into a more complicated blocker with an overflow error derived from matplotlib's handling of dates as integer. I get around the overflow issue with some manipulation of the object state, but some of the fix is admittedly imperfect. Nonetheless, this code alleviates the original problem seen with datetime64[ns] handling, see plot below for example code and plot:

import numpy as np
from seaborn import axisgrid as ag

dates = np.arange("2024-01-01", "2024-04-01", dtype="datetime64[D]").astype("datetime64[ns]")
random_dates = np.random.choice(dates, size=1000)
y = np.random.normal(size=1000)
plot = ag.jointplot(x=random_dates, y=y, kind="hex")

plot.fig.savefig("out.png")

out

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

Successfully merging this pull request may close these issues.

1 participant