Reputation: 16488
I'm having a pandas
dataset that contains an integer and a float value:
>>> df2[['AGE_REF', 'RETSURV']].dtypes
AGE_REF int64
RETSURV float64
dtype: object
I'd like to plot the joint distribution using pandas. I didn't see a simple way of pandas visualizing the joint distribution, but I stumbled across seaborn
. So I tried to adjust code that I already found for my purposes:
>>> import seaborn as sns
>>> sns.jointplot('AGE_REF', "RETSURV", df2,
kind="hex")
Traceback (most recent call last):
File "<input>", line 2, in <module>
File "/usr/local/lib/python2.7/site-packages/seaborn/distributions.py", line 969, in jointplot
gridsize = int(np.mean([x_bins, y_bins]))
OverflowError: cannot convert float infinity to integer
I found a related bug report, so I tried to follow the workaround there - without success:
>>> sns.jointplot('AGE_REF', "RETSURV", df2,
kind="hex", marginal_kws={"bins": 10})
Traceback (most recent call last):
File "<input>", line 2, in <module>
File "/usr/local/lib/python2.7/site-packages/seaborn/distributions.py", line 969, in jointplot
gridsize = int(np.mean([x_bins, y_bins]))
OverflowError: cannot convert float infinity to integer
Upvotes: 0
Views: 1228
Reputation: 49002
The default hexbin gridsize uses the same reference rule calculation as the histograms, so you'll need to set that directly too if you have data that violate those assumptions somehow:
sns.jointplot(x, y, kind="hex",
joint_kws={"gridsize": 10},
marginal_kws={"bins": 10})
Upvotes: 1