Title: Major speed regression introduced in "plt.bar" definition clipping between 3.0.3 and 3.3.0. · Issue #17974 · matplotlib/matplotlib · GitHub
Open Graph Title: Major speed regression introduced in "plt.bar" definition clipping between 3.0.3 and 3.3.0. · Issue #17974 · matplotlib/matplotlib
X Title: Major speed regression introduced in "plt.bar" definition clipping between 3.0.3 and 3.3.0. · Issue #17974 · matplotlib/matplotlib
Description: Bug report Bug summary As I updated Matplolib from version 3.0.3 to version 3.3.0 I noticed that Colour unit test time skyrocketed: our plotting sub-package test suite went from 120 seconds to around 3000 seconds! I quickly noticed that ...
Open Graph Description: Bug report Bug summary As I updated Matplolib from version 3.0.3 to version 3.3.0 I noticed that Colour unit test time skyrocketed: our plotting sub-package test suite went from 120 seconds to arou...
X Description: Bug report Bug summary As I updated Matplolib from version 3.0.3 to version 3.3.0 I noticed that Colour unit test time skyrocketed: our plotting sub-package test suite went from 120 seconds to arou...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/17974
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Major speed regression introduced in \"plt.bar\" definition clipping between 3.0.3 and 3.3.0.","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**Bug summary**\r\n\r\nAs I updated Matplolib from version 3.0.3 to version 3.3.0 I noticed that [Colour](https://github.com/colour-science/colour/) unit test time skyrocketed: our plotting sub-package test suite went from 120 seconds to around 3000 seconds!\r\n\r\nI quickly noticed that it was related to definitions using the spectrum plot:\r\n\r\n\r\n\r\nThis definition is using `plt.bar` and as I suspected that polygon clipping might be the culprit, I ran some tests on one of the offending definitions while keeping and removing the polygon clipping:\r\n\r\n*With Polygon Clipping*\r\n\r\n```python\r\n\u003e\u003e\u003e import timeit\r\n\u003e\u003e\u003e import colour\r\n\u003e\u003e\u003e timeit.timeit(lambda : colour.plotting.plot_single_illuminant_sd(filename='test.png'), number=1)\r\n59.81594165299998\r\n```\r\n\r\n*Without Polygon Clipping*\r\n```python\r\n\u003e\u003e\u003e import timeit\r\n\u003e\u003e\u003e import colour\r\n\u003e\u003e\u003e timeit.timeit(lambda : colour.plotting.plot_single_illuminant_sd(filename='test.png'), number=1)\r\n1.3159556400000056\r\n```\r\n\r\n**Code for reproduction**\r\n\r\n\u003c!--A minimum code snippet required to reproduce the bug.\r\nPlease make sure to minimize the number of dependencies required, and provide\r\nany necessary plotted data.\r\nAvoid using threads, as Matplotlib is (explicitly) not thread-safe.--\u003e\r\n\r\nI haven't created a reproducible case but my assumption is that the clipping code is orders of magnitude slower than before, the definition I used is available here: https://github.com/colour-science/colour/blob/d5f68005f62fc86ba59745bd4c8bb8a01bb5dcb4/colour/plotting/colorimetry.py#L183 and the meat is roughly as follows:\r\n\r\n```python\r\n polygon = Polygon(\r\n np.vstack([\r\n (x_min, 0),\r\n tstack([wavelengths, values]),\r\n (x_max, 0),\r\n ]),\r\n facecolor='none',\r\n edgecolor='none')\r\n axes.add_patch(polygon)\r\n\r\n padding = 0.1\r\n axes.bar(\r\n x=wavelengths - padding,\r\n height=max(values),\r\n width=1 + padding,\r\n color=colours,\r\n align='edge',\r\n clip_path=polygon)\r\n```\r\n\r\nThere are roughly 450 wavelengths and each one of them generates a coloured bar.\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: macOS 10.15.5\r\n * Matplotlib version: 3.3.0\r\n * Matplotlib backend (`print(matplotlib.get_backend())`): MacOSX\r\n * Python version: 3.8\r\n * Jupyter version (if applicable):\r\n * Other libraries: \r\n\r\n\u003c!--Please tell us how you installed matplotlib and python e.g., from source, pip, conda--\u003e\r\n\u003c!--If you installed from conda, please specify which channel you used if not the default--\u003e\r\n\r\nMatplotlib was installed with Pip.\r\n\r\n","author":{"url":"https://github.com/thomasmansencal","@type":"Person","name":"thomasmansencal"},"datePublished":"2020-07-20T11:45:02.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":10},"url":"https://github.com/17974/matplotlib/issues/17974"}
| 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:9a8fc0bd-21d2-0b38-683f-ef49f076cb90 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8218:2D7C5C:BEDF91:101A336:6A51F0E1 |
| html-safe-nonce | 15172aa270b4e426d35d89bd718037b2d8e6296dad524925864b72ff410dc0f7 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4MjE4OjJEN0M1QzpCRURGOTE6MTAxQTMzNjo2QTUxRjBFMSIsInZpc2l0b3JfaWQiOiIzNzQ3NTYwNTQ2NDEyNzUxMDUiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | b33d22c7403aebbe956620a1882c05cd383cded5ee0d6d671271f6982c46bc4c |
| hovercard-subject-tag | issue:661724956 |
| 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/17974/issue_layout |
| twitter:image | https://opengraph.githubassets.com/f74b020fff50f8f3bd1f9686cbe952d0bb6baa0249263da5e32261a73557bb60/matplotlib/matplotlib/issues/17974 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/f74b020fff50f8f3bd1f9686cbe952d0bb6baa0249263da5e32261a73557bb60/matplotlib/matplotlib/issues/17974 |
| og:image:alt | Bug report Bug summary As I updated Matplolib from version 3.0.3 to version 3.3.0 I noticed that Colour unit test time skyrocketed: our plotting sub-package test suite went from 120 seconds to arou... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | thomasmansencal |
| hostname | github.com |
| expected-hostname | github.com |
| None | b9a586c06a05a7a86fc7e3f4dbd03e42f6869085879aa184aa6369456dbd50fb |
| 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 | 7aed05249554b889eb33d002851a973eebcc7e91 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width