Title: Axes instantiation is very slow · Issue #6664 · matplotlib/matplotlib · GitHub
Open Graph Title: Axes instantiation is very slow · Issue #6664 · matplotlib/matplotlib
X Title: Axes instantiation is very slow · Issue #6664 · matplotlib/matplotlib
Description: > python -V Python 2.7.11 > pip freeze | grep matplotlib matplotlib==1.5.1 > python -m platform -s "print platform()" Windows-7-6.1.7601-SP2 I have discovered that my application spends a lot of time in Axes creation. Results of class in...
Open Graph Description: > python -V Python 2.7.11 > pip freeze | grep matplotlib matplotlib==1.5.1 > python -m platform -s "print platform()" Windows-7-6.1.7601-SP2 I have discovered that my application spends a lot of ti...
X Description: > python -V Python 2.7.11 > pip freeze | grep matplotlib matplotlib==1.5.1 > python -m platform -s "print platform()" Windows-7-6.1.7601-SP2 I have discovered that my application...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/6664
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Axes instantiation is very slow","articleBody":"``` cmd\n\u003e python -V\nPython 2.7.11\n\u003e pip freeze | grep matplotlib\nmatplotlib==1.5.1\n\u003e python -m platform -s \"print platform()\"\nWindows-7-6.1.7601-SP2\n```\n\nI have discovered that my application spends a lot of time in Axes creation. Results of class instantiation profiling is below:\n\n``` cmd\n\u003e python -m timeit -s \"from matplotlib.figure import Figure; from matplotlib.axes import Axes; fig = Figure()\" \"Axes(fig, (0, 0, 1 ,1))\"\n10 loops, best of 3: 33.2 msec per loop\n```\n\n\nInside `Axes.__init__` most of the execution time takes `self.cla()` call and about the half of it is\n[this loop below](https://github.com/matplotlib/matplotlib/blob/a8ad349c583b79ee24e749497381ab026ac5a360/lib/matplotlib/axes/_base.py#L952-L953)\n\n``` python\n for name, spine in six.iteritems(self.spines):\n spine.cla()\n```\n\nAfter commenting this two lines I have got this:\n\n``` cmd\n\u003e python -m timeit -s \"from matplotlib.figure import Figure; from matplotlib.axes import Axes; fig = Figure()\" \"Axes(fig, (0, 0, 1 ,1))\"\n100 loops, best of 3: 17.9 msec per loop\n```\n\nSo we have 33 ms per axes creation, and the half of this time it is used for spines creation that actually may be not used (in my case I have bunch of sharex axes and only one of them have spines).\nI see a possible solution where creation of spines, scales (you can see creation of logarithmic scale, which I do not use too) and other stuff is delayed to the point when it actually needed/initialized.\n\nAnd the fun part. For 20 created Axes we have 60115 calls to `Rectangle.stale` (3005 call per Axes instantiation)\n\n","author":{"url":"https://github.com/Kojoley","@type":"Person","name":"Kojoley"},"datePublished":"2016-06-28T18:31:21.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":34},"url":"https://github.com/6664/matplotlib/issues/6664"}
| 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:2628243f-de02-7c49-7498-d17b2f929c19 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8920:1EFAFB:BEFF62:1008200:6A52C0F4 |
| html-safe-nonce | e3d5be4c5fce0707262c907365eed5f93fe78a3c48399f7947122c85b3e8aaf9 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4OTIwOjFFRkFGQjpCRUZGNjI6MTAwODIwMDo2QTUyQzBGNCIsInZpc2l0b3JfaWQiOiI2NjkxMDc1ODgxMTg1MjgyNDQiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 33945bb7ccbb71aaf1335b7920d004f14e8cc0aee157094d6de38cfbcc38492e |
| hovercard-subject-tag | issue:162754690 |
| 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/6664/issue_layout |
| twitter:image | https://opengraph.githubassets.com/cc8aa3926b80523f4215060d9195e03044fdaf5ffecf7691f6952594749e38c7/matplotlib/matplotlib/issues/6664 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/cc8aa3926b80523f4215060d9195e03044fdaf5ffecf7691f6952594749e38c7/matplotlib/matplotlib/issues/6664 |
| og:image:alt | > python -V Python 2.7.11 > pip freeze | grep matplotlib matplotlib==1.5.1 > python -m platform -s "print platform()" Windows-7-6.1.7601-SP2 I have discovered that my application spends a lot of ti... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Kojoley |
| 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 | 07a982c1d40157c619b364352b704c3ce66bb332 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width