Title: Default legend behavior (loc='best') very slow for large amounts of data. · Issue #12120 · matplotlib/matplotlib · GitHub
Open Graph Title: Default legend behavior (loc='best') very slow for large amounts of data. · Issue #12120 · matplotlib/matplotlib
X Title: Default legend behavior (loc='best') very slow for large amounts of data. · Issue #12120 · matplotlib/matplotlib
Description: Bug report Plotting large amounts of data with legend is slow when legend is using best location. Code for reproduction import numpy as np import matplotlib.pyplot as plt import matplotlib as mpl # Setup, and create the data to plot y = ...
Open Graph Description: Bug report Plotting large amounts of data with legend is slow when legend is using best location. Code for reproduction import numpy as np import matplotlib.pyplot as plt import matplotlib as mpl #...
X Description: Bug report Plotting large amounts of data with legend is slow when legend is using best location. Code for reproduction import numpy as np import matplotlib.pyplot as plt import matplotlib as mpl #...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/12120
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Default legend behavior (loc='best') very slow for large amounts of data.","articleBody":"\u003c!--To help us understand and resolve your issue, please fill out the form to the best of your ability.--\u003e\r\n\u003c!--You can feel free to delete the sections that do not apply.--\u003e\r\n\r\n### Bug report\r\n\r\n**Plotting large amounts of data with legend is slow when legend is using `best` location.**\r\n\r\n\u003c!--A short 1-2 sentences that succinctly describes the bug--\u003e\r\n\r\n**Code for reproduction**\r\n\r\n\u003c!--A minimum code snippet required to reproduce the bug, also minimizing the number of dependencies required--\u003e\r\n\r\n```python\r\nimport numpy as np\r\nimport matplotlib.pyplot as plt\r\nimport matplotlib as mpl\r\n\r\n# Setup, and create the data to plot\r\ny = np.random.rand(10000000)\r\n# Adapted from https://matplotlib.org/tutorials/introductory/usage.html#performance\r\nmpl.rcParams['path.simplify'] = True\r\nmpl.rcParams['path.simplify_threshold'] = 1.0\r\n\r\nplt.plot(y, label='data')\r\nplt.legend(loc='best')\r\nplt.show()\r\n\r\nplt.plot(y, label='data')\r\nplt.legend(loc='upper right')\r\nplt.show()\r\n\r\n\r\n```\r\n\r\n**Actual outcome**\r\n\r\nThe first plot is much slower (`loc='best'`) than the second.\r\n\r\n**Matplotlib version**\r\n\u003c!--Please specify your platform and versions of the relevant libraries you are using:--\u003e\r\n * Operating system: Ubuntu 18.04\r\n * Matplotlib version: 2.1.x and 2.2.x\r\n * Matplotlib backend (`print(matplotlib.get_backend())`): Qt5Agg, TkAgg\r\n * Python version: 3.7\r\n * Jupyter version (if applicable): N/A\r\n * Other libraries: numpy 1.15.1\r\n\r\nInstalled via conda.\r\n\r\n--------------------------------------------\r\n\r\nI think it'd be fine to just note this in the performance section of the User Guide (https://matplotlib.org/tutorials/introductory/usage.html#performance). I could also try looking into speeding up the `best` location finder but I get the feeling that'd be a fairly slow project.\r\n\r\nCurious to hear what others think.","author":{"url":"https://github.com/kbrose","@type":"Person","name":"kbrose"},"datePublished":"2018-09-14T18:04:13.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":5},"url":"https://github.com/12120/matplotlib/issues/12120"}
| 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:d9a10da3-8e82-4bcc-8b42-540f59c8772a |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E724:3BEBFA:2E59C9F:418BE0C:6A54C5BA |
| html-safe-nonce | 3e9b5f8fe5d0854c17293d5138becd0c82578969f79b3e8160f538a3f6839740 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFNzI0OjNCRUJGQToyRTU5QzlGOjQxOEJFMEM6NkE1NEM1QkEiLCJ2aXNpdG9yX2lkIjoiNDI1MzYyODUwMzg0NzkxMjg5MCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | d8ac7db2bf289771bdd367ce16b886e5e95ed59e73efe4f307ea75533dec97b2 |
| hovercard-subject-tag | issue:360401389 |
| 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/matplotlib/matplotlib/12120/issue_layout |
| twitter:image | https://opengraph.githubassets.com/6761b5b561896d2be3476347cfb4498c06ae39f9cc143671962f23b7463476bb/matplotlib/matplotlib/issues/12120 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/6761b5b561896d2be3476347cfb4498c06ae39f9cc143671962f23b7463476bb/matplotlib/matplotlib/issues/12120 |
| og:image:alt | Bug report Plotting large amounts of data with legend is slow when legend is using best location. Code for reproduction import numpy as np import matplotlib.pyplot as plt import matplotlib as mpl #... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | kbrose |
| hostname | github.com |
| expected-hostname | github.com |
| None | 6e5f2e6ff3f430aa60a674066f957bca9f2106017e1b68126417422b58ce6e1e |
| turbo-cache-control | no-preview |
| go-import | github.com/matplotlib/matplotlib git https://github.com/matplotlib/matplotlib.git |
| octolytics-dimension-user_id | 215947 |
| octolytics-dimension-user_login | matplotlib |
| octolytics-dimension-repository_id | 1385122 |
| octolytics-dimension-repository_nwo | matplotlib/matplotlib |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 1385122 |
| octolytics-dimension-repository_network_root_nwo | matplotlib/matplotlib |
| 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 | be4d48619391052c9d312c7b587bb2ac38a97f57 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width