Title: Different result, slower runtime of heatmap between 2.0.0 and 2.0.1 · Issue #8947 · matplotlib/matplotlib · GitHub
Open Graph Title: Different result, slower runtime of heatmap between 2.0.0 and 2.0.1 · Issue #8947 · matplotlib/matplotlib
X Title: Different result, slower runtime of heatmap between 2.0.0 and 2.0.1 · Issue #8947 · matplotlib/matplotlib
Description: Bug report Bug summary I am using Matplotlib with Basemap to create heatmaps of data. A change introduced between version 2.0.0 and 2.0.1 caused my code to: Produce a different result Run significantly slower The problem still seems to e...
Open Graph Description: Bug report Bug summary I am using Matplotlib with Basemap to create heatmaps of data. A change introduced between version 2.0.0 and 2.0.1 caused my code to: Produce a different result Run significa...
X Description: Bug report Bug summary I am using Matplotlib with Basemap to create heatmaps of data. A change introduced between version 2.0.0 and 2.0.1 caused my code to: Produce a different result Run significa...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/8947
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Different result, slower runtime of heatmap between 2.0.0 and 2.0.1","articleBody":"### Bug report\r\n\r\n**Bug summary**\r\n\r\nI am using Matplotlib with Basemap to create heatmaps of data.\r\nA change introduced between version 2.0.0 and 2.0.1 caused my code to:\r\n* Produce a different result\r\n* Run significantly slower\r\n\r\nThe problem still seems to exist in 2.0.2.\r\n\r\nI also ran some profiling to have a look at the differences, and the increase in time seems to be in the `resample` function (from 0.473s total time to 19.042s total time)\r\n\r\n**Code for reproduction**\r\n\r\n```python\r\nimport csv\r\nimport time\r\n\r\nimport numpy as np\r\nimport matplotlib\r\nimport matplotlib.pyplot as plt\r\nimport matplotlib.cm as cm\r\nfrom mpl_toolkits.basemap import Basemap\r\n\r\n\r\ndef create_basemap():\r\n m = Basemap(projection='cyl', llcrnrlat=-90, urcrnrlat=90,\r\n llcrnrlon=-180, urcrnrlon=180, resolution='c')\r\n m.drawmapboundary(fill_color='#b4d0d0')\r\n m.drawcoastlines(linewidth=0.25, color=\"#ffffff\")\r\n m.fillcontinents(color=\"grey\", lake_color='#b4d0d0')\r\n\r\n m.drawparallels(np.arange(-90., 91., 30.), linewidth=\"0.25\", color=\"#333333\")\r\n m.drawmeridians(np.arange(-180., 181., 60.), linewidth=\"0.25\", color=\"#555555\")\r\n return m\r\n\r\n\r\ndef create_heatmap(positions):\r\n heatmap = np.zeros((180, 360))\r\n extents = [[-90, 90], [-180, 180]]\r\n\r\n lats, lons = map(list, zip(*positions))\r\n\r\n subheatmap, xedges, yedges = np.histogram2d(lats, lons, bins=[180, 360], range=extents)\r\n extent = [xedges[0], xedges[-1], yedges[0], yedges[-1]]\r\n heatmap = np.add(heatmap, subheatmap)\r\n\r\n fig = plt.figure()\r\n m = create_basemap()\r\n\r\n cmap = cm.jet\r\n cmap.set_bad(alpha=0.0)\r\n\r\n im = m.imshow(heatmap, cmap=cmap, interpolation='bicubic', extent=extent, origin='lower', alpha=1.0, norm=matplotlib.colors.LogNorm(), vmin=1, vmax=2, zorder=100)\r\n cb = fig.colorbar(im, shrink=0.5, format=\"%d\")\r\n\r\n plt.title(\"Test\")\r\n plt.savefig(\"test.png\", dpi=500, bbox_inches='tight', pad_inches=0.1)\r\n plt.close()\r\n\r\n\r\npositions = [(50, i) for i in range(50)]\r\nstart = time.time()\r\ncreate_heatmap(positions)\r\nprint \"Runtime: {0}\".format(time.time() - start)\r\n```\r\n\r\n**Version 2.0.0 outcome**\r\n\r\n```\r\nRuntime: 2.31200003624\r\n```\r\n\r\n\r\n`python -m cProfile --sort=tottime script.py`:\r\n```\r\n 667764 function calls (659117 primitive calls) in 3.555 seconds\r\n\r\n Ordered by: internal time\r\n\r\n ncalls tottime percall cumtime percall filename:lineno(function)\r\n 2 0.702 0.351 0.702 0.351 {matplotlib._png.write_png}\r\n 2 0.473 0.237 0.473 0.237 {matplotlib._image.resample}\r\n 1 0.138 0.138 0.138 0.138 {_tkinter.create}\r\n 890 0.117 0.000 0.117 0.000 {method 'is_valid' of '_geoslib.BaseGeometry' objects}\r\n 15 0.106 0.007 0.632 0.042 __init__.py:1(\u003cmodule\u003e)\r\n 1 0.090 0.090 0.135 0.135 __init__.py:14(\u003cmodule\u003e)\r\n 296 0.083 0.000 0.083 0.000 {method 'intersection' of '_geoslib.BaseGeometry' objects}\r\n 2 0.068 0.034 0.681 0.340 image.py:275(_make_image)\r\n 11413 0.055 0.000 0.058 0.000 {numpy.core.multiarray.array}\r\n 300 0.050 0.000 0.072 0.000 {method 'draw_path' of 'matplotlib.backends._backend_agg.RendererAgg' objects}\r\n...\r\n```\r\n\r\n**Version 2.0.1 outcome**\r\n```\r\nRuntime: 21.0169999599\r\n```\r\n\r\n\r\n`python -m cProfile --sort=tottime script.py`:\r\n```\r\n 1763720 function calls (1754827 primitive calls) in 23.725 seconds\r\n\r\n Ordered by: internal time\r\n\r\n ncalls tottime percall cumtime percall filename:lineno(function)\r\n 4 19.042 4.761 19.043 4.761 {matplotlib._image.resample}\r\n 2 0.735 0.367 0.735 0.367 {matplotlib._png.write_png}\r\n 2 0.609 0.304 1.377 0.688 font_manager.py:558(createFontList)\r\n 60 0.138 0.002 0.336 0.006 afm.py:181(_parse_char_metrics)\r\n 1 0.135 0.135 0.135 0.135 {_tkinter.create}\r\n 2 0.133 0.067 19.309 9.655 image.py:275(_make_image)\r\n 890 0.115 0.000 0.115 0.000 {method 'is_valid' of '_geoslib.BaseGeometry' objects}\r\n 1 0.107 0.107 0.159 0.159 __init__.py:14(\u003cmodule\u003e)\r\n 15 0.106 0.007 0.637 0.042 __init__.py:1(\u003cmodule\u003e)\r\n 559 0.104 0.000 0.104 0.000 {method 'get_sfnt' of 'matplotlib.ft2font.FT2Font' objects}\r\n```\r\n\r\n**Matplotlib version**\r\n * Operating System: Windows 10\r\n * Matplotlib Version: 2.0.0/2.0.1 (from pip)\r\n * Python Version: 2.7.13\r\n * Jupyter Version (if applicable): N/A\r\n * Other Libraries: basemap 1.1.0, numpy 1.13.1\r\n\r\n","author":{"url":"https://github.com/NickG123","@type":"Person","name":"NickG123"},"datePublished":"2017-07-27T20:31:33.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":10},"url":"https://github.com/8947/matplotlib/issues/8947"}
| 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:80e25168-066a-1a3d-0940-54859ce8bc2b |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 81AC:221685:255C025:31FE699:6A52127F |
| html-safe-nonce | aa73a48f8de9d8d633145ee5e666edec2e5a259bfe2756acf63fcae31343974e |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4MUFDOjIyMTY4NToyNTVDMDI1OjMxRkU2OTk6NkE1MjEyN0YiLCJ2aXNpdG9yX2lkIjoiNTQ4NzQ4MTk4NDE3ODU5MDMzNiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | de081f0126cd6caaec705c23e088d39e5c1bb090d53b67f92346f9d5c35c7e8b |
| hovercard-subject-tag | issue:246160222 |
| 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/8947/issue_layout |
| twitter:image | https://opengraph.githubassets.com/32dea35ae01e156238022ab08022af5fd112525bbe2440378ecfc47786e0cf95/matplotlib/matplotlib/issues/8947 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/32dea35ae01e156238022ab08022af5fd112525bbe2440378ecfc47786e0cf95/matplotlib/matplotlib/issues/8947 |
| og:image:alt | Bug report Bug summary I am using Matplotlib with Basemap to create heatmaps of data. A change introduced between version 2.0.0 and 2.0.1 caused my code to: Produce a different result Run significa... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | NickG123 |
| 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