-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Closed
Closed
Copy link
Description
It's possible (nay, likely) that I'm misunderstanding something but the docs indicate that Numpy arrays containing timestamps should be allowed. Yet, I'm currently having to cast this into a Pandas Series for it to work:
# plotly date axis bug?
import dash
import dash_core_components as dcc
import dash_html_components as html
import plotly.graph_objects as go
import numpy as np
import pandas as pd
app = dash.Dash(__name__)
timestamps = np.array(
[
'2017-05-24T23:00:21',
'2017-05-24T23:00:23',
'2017-05-24T23:00:25',
'2017-05-24T23:00:27',
'2017-05-24T23:00:29'
],
dtype='datetime64[ns]'
)
fake_data = np.arange(len(timestamps))
fig_working = go.Figure().add_scatter(
x=pd.Series(timestamps),
y=fake_data
).update_layout(xaxis_type='date')
fig_working_not_so_much = go.Figure().add_scatter(
x=timestamps,
y=fake_data
).update_layout(xaxis_type='date')
app.layout = html.Div(
[
html.H1("Working with a pandas.Series:"),
dcc.Graph(figure=fig_working),
html.H1("Same data in a numpy.array:"),
dcc.Graph(figure=fig_working_not_so_much),
html.H1("😿")
]
)
if __name__ == '__main__':
app.run_server(debug=True)
This yields:
Metadata
Metadata
Assignees
Labels
No labels