Title: Using 'date' type for scatter xaxis fails when coordinates stored in Numpy array · Issue #1927 · plotly/plotly.py · GitHub
Open Graph Title: Using 'date' type for scatter xaxis fails when coordinates stored in Numpy array · Issue #1927 · plotly/plotly.py
X Title: Using 'date' type for scatter xaxis fails when coordinates stored in Numpy array · Issue #1927 · plotly/plotly.py
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 ax...
Open Graph 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...
X 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 i...
Opengraph URL: https://github.com/plotly/plotly.py/issues/1927
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Using 'date' type for scatter xaxis fails when coordinates stored in Numpy array","articleBody":"It's possible (nay, likely) that I'm misunderstanding something but the [docs](https://plot.ly/python/reference/#scatter-x) 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:\r\n\r\n```python\r\n# plotly date axis bug?\r\nimport dash\r\nimport dash_core_components as dcc\r\nimport dash_html_components as html\r\nimport plotly.graph_objects as go\r\n\r\nimport numpy as np\r\nimport pandas as pd\r\n\r\n\r\napp = dash.Dash(__name__)\r\n\r\ntimestamps = np.array(\r\n [\r\n '2017-05-24T23:00:21',\r\n '2017-05-24T23:00:23',\r\n '2017-05-24T23:00:25',\r\n '2017-05-24T23:00:27',\r\n '2017-05-24T23:00:29'\r\n ],\r\n dtype='datetime64[ns]'\r\n)\r\nfake_data = np.arange(len(timestamps))\r\n\r\nfig_working = go.Figure().add_scatter(\r\n x=pd.Series(timestamps),\r\n y=fake_data\r\n).update_layout(xaxis_type='date')\r\n\r\n\r\nfig_working_not_so_much = go.Figure().add_scatter(\r\n x=timestamps,\r\n y=fake_data\r\n).update_layout(xaxis_type='date')\r\n\r\n\r\napp.layout = html.Div(\r\n [\r\n html.H1(\"Working with a pandas.Series:\"),\r\n dcc.Graph(figure=fig_working),\r\n\r\n html.H1(\"Same data in a numpy.array:\"),\r\n dcc.Graph(figure=fig_working_not_so_much),\r\n\r\n html.H1(\"😿\")\r\n ]\r\n)\r\n\r\n\r\nif __name__ == '__main__':\r\n app.run_server(debug=True)\r\n```\r\n\r\nThis yields:\r\n\r\n\r\n","author":{"url":"https://github.com/jordanweaver","@type":"Person","name":"jordanweaver"},"datePublished":"2019-11-25T19:51:59Z","url":"https://github.com/plotly/plotly.py/issues/1927"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:18987e7b-6878-608d-b080-1e823d4483b7 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | CFBC:87955:4DA228:6674C8:6B01776D |
| html-safe-nonce | 8e63090b20369e67d5016c5ae0abb85404f4fdb734eeedee80e961d97078230a |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDRkJDOjg3OTU1OjREQTIyODo2Njc0Qzg6NkIwMTc3NkQiLCJ2aXNpdG9yX2lkIjoiMTgyNDUyOTY2NTY0NjIyOTM1NyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 26a0cbdac97a65c9eaf9b0b48f0ebe3fe736cca38738be4dad01e75a49cd655d |
| hovercard-subject-tag | issue:528302190 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/plotly/plotly.py/1927/issue_layout |
| twitter:image | https://opengraph.githubassets.com/4e61a58b054cba6502411f341aa7398fd1e8b3c64fbde379a342bf4cf382d850/plotly/plotly.py/issues/1927 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/4e61a58b054cba6502411f341aa7398fd1e8b3c64fbde379a342bf4cf382d850/plotly/plotly.py/issues/1927 |
| og:image:alt | 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... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | jordanweaver |
| hostname | github.com |
| expected-hostname | github.com |
| None | cc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c |
| turbo-cache-control | no-preview |
| go-import | github.com/plotly/plotly.py git https://github.com/plotly/plotly.py.git |
| octolytics-dimension-user_id | 5997976 |
| octolytics-dimension-user_login | plotly |
| octolytics-dimension-repository_id | 14579099 |
| octolytics-dimension-repository_nwo | plotly/plotly.py |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 14579099 |
| octolytics-dimension-repository_network_root_nwo | plotly/plotly.py |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 8c77c9e8439031ad54c75a250694842892f693e1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width