Seaborn: distplot doesn't work with dates on the x axis

Created on 6 Nov 2018  路  1Comment  路  Source: mwaskom/seaborn

I'm attempting to re-open #1059, as seaborn should definitely be able to plot distributions over date ranges, and telling us to just use plt.hist is a work-around, not a solution. It sounds like a few changes in the calculations of the means and for colors and bin sizes should get it working (https://github.com/mwaskom/seaborn/issues/1059#issuecomment-254355469).

sb.distplot(np.arange('2016-01', '2016-05', dtype='datetime64[D]'))

TypeError                                 Traceback (most recent call last)
<ipython-input-174-b58909c41bc2> in <module>
----> 1 sb.distplot(np.arange('2016-01', '2016-05', dtype='datetime64[D]'))

/opt/conda/lib/python3.6/site-packages/seaborn/distributions.py in distplot(a, bins, hist, kde, rug, fit, hist_kws, kde_kws, rug_kws, fit_kws, color, vertical, norm_hist, axlabel, label, ax)
    196             line, = ax.plot(0, a.mean())
    197         else:
--> 198             line, = ax.plot(a.mean(), 0)
    199         color = line.get_color()
    200         line.remove()

/opt/conda/lib/python3.6/site-packages/numpy/core/_methods.py in _mean(a, axis, dtype, out, keepdims)
     73             is_float16_result = True
     74 
---> 75     ret = umr_sum(arr, axis, dtype, out, keepdims)
     76     if isinstance(ret, mu.ndarray):
     77         ret = um.true_divide(

TypeError: ufunc add cannot use operands with types dtype('<M8[D]') and dtype('<M8[D]')

I'm using seaborn 0.9.0 with numpy 1.15.2

>All comments

Duplicate of #1059

Was this page helpful?
0 / 5 - 0 ratings

Related issues

phantom0301 picture phantom0301  路  3Comments

sungshine picture sungshine  路  3Comments

songololo picture songololo  路  4Comments

stonebig picture stonebig  路  4Comments

TDaltonC picture TDaltonC  路  3Comments