Title: Sorting issues with multicategories · Issue #1491 · plotly/plotly.py · GitHub
Open Graph Title: Sorting issues with multicategories · Issue #1491 · plotly/plotly.py
X Title: Sorting issues with multicategories · Issue #1491 · plotly/plotly.py
Description: Hello, as you can see here my chart is not correctly sorted by the x-axis and the line goes back which is really not an expected behavior. I found out that a workaround is to add "missing" x labels (as in missing months in this case, see...
Open Graph Description: Hello, as you can see here my chart is not correctly sorted by the x-axis and the line goes back which is really not an expected behavior. I found out that a workaround is to add "missing" x labels...
X Description: Hello, as you can see here my chart is not correctly sorted by the x-axis and the line goes back which is really not an expected behavior. I found out that a workaround is to add "missing"...
Opengraph URL: https://github.com/plotly/plotly.py/issues/1491
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Sorting issues with multicategories","articleBody":"Hello,\r\n\r\nas you can see here my chart is not correctly sorted by the x-axis and the line goes back which is really not an expected behavior.\r\n\r\n\r\n\r\nI found out that a workaround is to add \"missing\" x labels (as in missing months in this case, see below) with None in y values but in my case it is very impractical.\r\n\r\n\r\n\r\nFirst of all it will make the graph overly large (spans over 5 years in some cases but I do not have data for all months, far from that). Also I'm using this graph with dash and the data gets transformed a lot which makes adding missing labels quite tedious.\r\n\r\nEDIT:\r\n\r\nAnother option you might think is to just use the month names in this case. Turns out that does not work either:\r\n\r\n\r\n\r\n\r\nThanks in advance for checking out the issue,\r\n\r\nThibault\r\n\r\n# Reproducible example with version 3.7.1 in offline mode\r\n\r\n```\r\nimport plotly.graph_objs as go\r\n\r\n\r\n\r\nx_axis = [[2017, 2017, 2017, 2017, 2017, 2017, 2017, 2017, 2018, 2018,2018, 2018], \r\n [4, 5, 6, 8, 9, 10, 11, 12, 1, 2, 3, 4]]\r\ny1 = [ 57246., 1587., 63189., 30680., 26071., 117519., 27519., 42643., 8559., 22355., 59363., 62955.]\r\ny2 = [0.22991999, 0.27284184, 0.18438336, 0.24866362, 0.18280848, 0.19382398, 0.17268069, 0.18802617, 0.17560463, 0.13415343, 0.14773512, 0.31319196]\r\n\r\n\r\n# all arrays must have the same length\r\nassert len(x_axis[0]) == len(x_axis[1]) == len(y1) == len(y2)\r\n\r\n\r\ntest_figure = go.Figure({\r\n 'data': [{'name': 'Fruits',\r\n 'type': 'bar',\r\n 'x': x_axis,\r\n 'y': y1},\r\n \r\n {'name': 'Price',\r\n 'type': 'scatter',\r\n 'x': x_axis,\r\n 'y': y2,\r\n 'yaxis': 'y2'}],\r\n \r\n \r\n 'layout': {'height': 600,\r\n 'showlegend': True,\r\n 'yaxis': {'showgrid': True, 'title': {'text': 'Fruits volume'}},\r\n 'yaxis2': {'anchor': 'x',\r\n 'overlaying': 'y',\r\n 'showgrid': False,\r\n 'side': 'right',\r\n 'title': {'text': 'Price per unit'}}}\r\n})\r\n\r\n\r\nfrom plotly.offline import download_plotlyjs, init_notebook_mode, plot, iplot\r\niplot(test_figure)\r\n```\r\n\r\n# Related issue on plotly.js\r\n\r\nThe issue I'm describing here should have been fixed in version 1.43.1 of plotly.js.\r\nSee https://github.com/plotly/plotly.js/blob/master/CHANGELOG.md#1431----2018-12-21\r\n(issue 3362)\r\n\r\nEven though plotly.py uses a superior version as you can see there is still an issue.","author":{"url":"https://github.com/ThibTrip","@type":"Person","name":"ThibTrip"},"datePublished":"2019-04-03T16:38:13Z","url":"https://github.com/plotly/plotly.py/issues/1491"}
| 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:50db077c-e5c1-98a0-cfb9-383f9956f57e |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E0A8:27E5CD:354C334:442E930:6B01DA7C |
| html-safe-nonce | faf33e4f69bef12a02fb605ebb6c1b00ce5751437dd34db2673a2be4c6e96f4a |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFMEE4OjI3RTVDRDozNTRDMzM0OjQ0MkU5MzA6NkIwMURBN0MiLCJ2aXNpdG9yX2lkIjoiODE4NzU3MTg5MTMxODQxMzk0OCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 7a7d88279268395c0f2f54f9565c43ebd13563d67c2122def5eb61f6da35afe2 |
| hovercard-subject-tag | issue:428867044 |
| 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/1491/issue_layout |
| twitter:image | https://opengraph.githubassets.com/15f61a570180f938253259d44815bd15b43a34ea21a32c9385b4a4238af280b3/plotly/plotly.py/issues/1491 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/15f61a570180f938253259d44815bd15b43a34ea21a32c9385b4a4238af280b3/plotly/plotly.py/issues/1491 |
| og:image:alt | Hello, as you can see here my chart is not correctly sorted by the x-axis and the line goes back which is really not an expected behavior. I found out that a workaround is to add "missing" x labels... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | ThibTrip |
| 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