[SOLVED] Dash isn't plotting datetime Indices from pandas?

Say I have a pandas DataFrame object that looks like this:

df.info()

<class 'pandas.core.frame.DataFrame'>
DatetimeIndex: 232 entries, 2017-08-20 14:30:22 to 2017-08-21 10:08:02
Data columns (total 1 columns):
S_dw    232 non-null float64
dtypes: float64(1)
memory usage: 3.6 KB

If I pass this df to go.Scatterplot and produce data as data = [go.Scatter(x=df.index, y=df[variable])], then py.iplot(data) generates a plotly plot with the correct x-axis of dates:

But the same df used in an app.callback function of Dash yields an empty graph and an x-axis with integer values. The y-axis is correctly scaled in both cases, and axis titles update, so I know the app.callback is working fine.

I’ve tried this a few different ways, and verified that the x-axis plots if I just use x=np.arange(len(df)) in Dash. I’m not getting any errors, so can’t debug this further. Any advice or suggestions would be really helpful.

Thanks for reporting @Kcaylor !

Would it be possible for you to create a simple, reproducable example that I can use to debug on my machine?

Hi @chriddyp - Thanks for the quick reply. I found the issue while putting together the example. I was bone-headedly using an axis property that specified the x-axis type as linear. So Dash was doing exactly what I was asking it to do, but I was asking for something I didn’t want.

1 Like