Title: matplotlib 3.5 breaks yt · Issue #20520 · matplotlib/matplotlib · GitHub
Open Graph Title: matplotlib 3.5 breaks yt · Issue #20520 · matplotlib/matplotlib
X Title: matplotlib 3.5 breaks yt · Issue #20520 · matplotlib/matplotlib
Description: Bug report Bug summary I found a regression in yt (https://github.com/yt-project/yt) by running our CI against matplotlib's master branch. Code for reproduction Here's a "minimal" script using yt's api from yt.testing import fake_sph_gri...
Open Graph Description: Bug report Bug summary I found a regression in yt (https://github.com/yt-project/yt) by running our CI against matplotlib's master branch. Code for reproduction Here's a "minimal" script using yt's...
X Description: Bug report Bug summary I found a regression in yt (https://github.com/yt-project/yt) by running our CI against matplotlib's master branch. Code for reproduction Here's a "minimal"...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/20520
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"matplotlib 3.5 breaks yt","articleBody":"### Bug report\r\n\r\n**Bug summary**\r\n\r\nI found a regression in yt (https://github.com/yt-project/yt) by running our CI against matplotlib's master branch.\r\n\r\n**Code for reproduction**\r\n\r\nHere's a \"minimal\" script using yt's api\r\n```python\r\nfrom yt.testing import fake_sph_grid_ds\r\nfrom yt.visualization.plot_window import ProjectionPlot\r\n\r\nds = fake_sph_grid_ds()\r\nplot = ProjectionPlot(ds, \"z\", (\"gas\", \"density\"))\r\nplot.save()\r\n```\r\nI apologise for not being able to provide a pure mpl minimal example at the moment. The data flow is unfortunately very hard to keep track of on the yt side, but I'm working on it.\r\nI think a better approach might be to go through the diff from the breaking commit and attempt a patch from there. I will attempt this and report here.\r\n\r\n**Actual outcome**\r\n\r\nHere's the traceback (using rich)\r\n```\r\nyt : [INFO ] 2021-06-25 17:00:25,961 Parameters: current_time = 0.0\r\nyt : [INFO ] 2021-06-25 17:00:25,961 Parameters: domain_dimensions = [1 1 1]\r\nyt : [INFO ] 2021-06-25 17:00:25,961 Parameters: domain_left_edge = [0. 0. 0.]\r\nyt : [INFO ] 2021-06-25 17:00:25,961 Parameters: domain_right_edge = [3. 3. 3.]\r\nyt : [INFO ] 2021-06-25 17:00:25,962 Parameters: cosmological_simulation = 0\r\nyt : [INFO ] 2021-06-25 17:00:25,962 Allocating for 2.700e+01 particles\r\nyt : [INFO ] 2021-06-25 17:00:28,828 xlim = 0.000000 3.000000\r\nyt : [INFO ] 2021-06-25 17:00:28,828 ylim = 0.000000 3.000000\r\nyt : [INFO ] 2021-06-25 17:00:28,828 xlim = 0.000000 3.000000\r\nyt : [INFO ] 2021-06-25 17:00:28,828 ylim = 0.000000 3.000000\r\nyt : [INFO ] 2021-06-25 17:00:28,836 Making a fixed resolution buffer of (('gas', 'density')) 800 by 800\r\n\u003e /Users/robcleme/dev/yt-project/yt-py310/yt/visualization/plot_window.py(1072)_setup_plots()\r\n 1070 #balise 3\r\n 1071 # THE ISSUE IS HERE\r\n-\u003e 1072 self.plots = WindowPlotMPL(\r\n 1073 ia,\r\n 1074 self._field_transform.name,\r\n\r\n(Pdbr) c\r\n\u003e /Users/robcleme/dev/yt-project/yt-py310/yt/visualization/base_plot_types.py(238)_init_image()\r\n 236 # tuple colormaps are from palettable (or brewer2mpl)\r\n 237 breakpoint()\r\n--\u003e 238 if isinstance(cmap, tuple):\r\n 239 cmap = get_brewer_cmap(cmap)\r\n 240\r\n\r\n(Pdbr) c\r\n\u003e /Users/robcleme/dev/yt-project/yt-py310/yt/visualization/plot_window.py(1072)_setup_plots()\r\n 1070 #balise 3\r\n 1071 # THE ISSUE IS HERE\r\n-\u003e 1072 self.plots = WindowPlotMPL(\r\n 1073 ia,\r\n 1074 self._field_transform.name,\r\n\r\n(Pdbr) c\r\n\u003e /Users/robcleme/dev/yt-project/yt-py310/yt/visualization/base_plot_types.py(238)_init_image()\r\n 236 # tuple colormaps are from palettable (or brewer2mpl)\r\n 237 breakpoint()\r\n--\u003e 238 if isinstance(cmap, tuple):\r\n 239 cmap = get_brewer_cmap(cmap)\r\n 240\r\n\r\n(Pdbr) c\r\n╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮\r\n│ /Users/robcleme/dev/yt-project/yt-py310/repro_mpl_bug.py:49 in \u003cmodule\u003e │\r\n│ │\r\n│ 46 │ return 0 │\r\n│ 47 │\r\n│ 48 if __name__ == \"__main__\": │\r\n│ ❱ 49 │ sys.exit(main()) │\r\n│ │\r\n│ /Users/robcleme/dev/yt-project/yt-py310/repro_mpl_bug.py:25 in main │\r\n│ │\r\n│ 22 │ │\r\n│ 23 │ ds = fake_sph_grid_ds() │\r\n│ 24 │ plot = ProjectionPlot(ds, \"z\", (\"gas\", \"density\")) │\r\n│ ❱ 25 │ plot.save() │\r\n│ 26 │ return 0 │\r\n│ 27 │\r\n│ 28 def main2() -\u003e int: │\r\n│ │\r\n│ /Users/robcleme/dev/yt-project/yt-py310/yt/visualization/plot_container.py:106 in newfunc │\r\n│ │\r\n│ 103 │ │ if not args[0]._plot_valid: │\r\n│ 104 │ │ │ # it is the responsibility of _setup_plots to │\r\n│ 105 │ │ │ # call args[0].run_callbacks() │\r\n│ ❱ 106 │ │ │ args[0]._setup_plots() │\r\n│ 107 │ │ rv = f(*args, **kwargs) │\r\n│ 108 │ │ return rv │\r\n│ 109 │\r\n│ │\r\n│ /Users/robcleme/dev/yt-project/yt-py310/yt/visualization/plot_window.py:1072 in _setup_plots │\r\n│ │\r\n│ 1069 │ │ │ breakpoint() │\r\n│ 1070 │ │ │ #balise 3 │\r\n│ 1071 │ │ │ # THE ISSUE IS HERE │\r\n│ ❱ 1072 │ │ │ self.plots[f] = WindowPlotMPL( │\r\n│ 1073 │ │ │ │ ia, │\r\n│ 1074 │ │ │ │ self._field_transform[f].name, │\r\n│ 1075 │ │ │ │ self._field_transform[f].func, │\r\n│ │\r\n│ /Users/robcleme/dev/yt-project/yt-py310/yt/visualization/plot_window.py:2268 in __init__ │\r\n│ │\r\n│ 2265 │ │ │\r\n│ 2266 │ │ super().__init__(size, axrect, caxrect, zlim, figure, axes, cax) │\r\n│ 2267 │ │ │\r\n│ ❱ 2268 │ │ self._init_image(data, cbname, cblinthresh, cmap, extent, aspect) │\r\n│ 2269 │ │ │\r\n│ 2270 │ │ # In matplotlib 2.1 and newer we'll be able to do this using │\r\n│ 2271 │ │ # self.image.axes.ticklabel_format │\r\n│ │\r\n│ /Users/robcleme/dev/yt-project/yt-py310/yt/visualization/base_plot_types.py:327 in _init_image │\r\n│ │\r\n│ 324 │ │ else: │\r\n│ 325 │ │ │ # this is where it breaks (but only on second pass) │\r\n│ 326 │ │ │ #breakpoint() │\r\n│ ❱ 327 │ │ │ self.cb = self.figure.colorbar(self.image, self.cax) │\r\n│ 328 │ │ for which in [\"major\", \"minor\"]: │\r\n│ 329 │ │ │ self.cax.tick_params(which=which, axis=\"y\", direction=\"in\") │\r\n│ 330 │\r\n│ │\r\n│ /Users/robcleme/dev/yt-project/yt-py310/matplotlib/lib/matplotlib/figure.py:1156 in colorbar │\r\n│ │\r\n│ 1153 │ │ │ │ │ │ │ 'panchor'] │\r\n│ 1154 │ │ cb_kw = {k: v for k, v in kw.items() if k not in NON_COLORBAR_KEYS} │\r\n│ 1155 │ │ │\r\n│ ❱ 1156 │ │ cb = cbar.Colorbar(cax, mappable, **cb_kw) │\r\n│ 1157 │ │ │\r\n│ 1158 │ │ if not kw['userax']: │\r\n│ 1159 │ │ │ self.sca(current_ax) │\r\n│ │\r\n│ /Users/robcleme/dev/yt-project/yt-py310/matplotlib/lib/matplotlib/colorbar.py:1196 in __init__ │\r\n│ │\r\n│ 1193 │ │ │ │ kwargs.setdefault('extend', mappable.cmap.colorbar_extend) │\r\n│ 1194 │ │ │ if isinstance(mappable, martist.Artist): │\r\n│ 1195 │ │ │ │ _add_disjoint_kwargs(kwargs, alpha=mappable.get_alpha()) │\r\n│ ❱ 1196 │ │ │ super().__init__(ax, **kwargs) │\r\n│ 1197 │ │ │\r\n│ 1198 │ │ mappable.colorbar = self │\r\n│ 1199 │ │ mappable.colorbar_cid = mappable.callbacksSM.connect( │\r\n│ │\r\n│ /Users/robcleme/dev/yt-project/yt-py310/matplotlib/lib/matplotlib/_api/deprecation.py:489 in │\r\n│ wrapper │\r\n│ │\r\n│ 486 │ │ │ │ \"positionally is deprecated since Matplotlib %(since)s; the \" │\r\n│ 487 │ │ │ │ \"parameter will become keyword-only %(removal)s.\", │\r\n│ 488 │ │ │ │ name=name, obj_type=f\"parameter of {func.__name__}()\") │\r\n│ ❱ 489 │ │ return func(*args, **kwargs) │\r\n│ 490 │ │\r\n│ 491 │ return wrapper │\r\n│ 492 │\r\n│ │\r\n│ /Users/robcleme/dev/yt-project/yt-py310/matplotlib/lib/matplotlib/colorbar.py:421 in __init__ │\r\n│ │\r\n│ 418 │ │ │ ['uniform', 'proportional'], spacing=spacing) │\r\n│ 419 │ │ │\r\n│ 420 │ │ # wrap the axes so that it can be positioned as an inset axes: │\r\n│ ❱ 421 │ │ ax = ColorbarAxes(ax, userax=userax) │\r\n│ 422 │ │ self.ax = ax │\r\n│ 423 │ │ ax.set(navigate=False) │\r\n│ 424 │\r\n│ │\r\n│ /Users/robcleme/dev/yt-project/yt-py310/matplotlib/lib/matplotlib/colorbar.py:260 in __init__ │\r\n│ │\r\n│ 257 │ │ │ │ parent._axes.add_child_axes(outer_ax) │\r\n│ 258 │ │ │ │ outer_ax._axes.child_axes.remove(parent) │\r\n│ 259 │ │ │ else: │\r\n│ ❱ 260 │ │ │ │ parent.remove() │\r\n│ 261 │ │ else: │\r\n│ 262 │ │ │ outer_ax = parent │\r\n│ 263 │\r\n│ │\r\n│ /Users/robcleme/dev/yt-project/yt-py310/matplotlib/lib/matplotlib/artist.py:163 in remove │\r\n│ │\r\n│ 160 │ │ # protected attribute if Python supported that sort of thing. The │\r\n│ 161 │ │ # callback has one parameter, which is the child to be removed. │\r\n│ 162 │ │ if self._remove_method is not None: │\r\n│ ❱ 163 │ │ │ self._remove_method(self) │\r\n│ 164 │ │ │ # clear stale callback │\r\n│ 165 │ │ │ self.stale_callback = None │\r\n│ 166 │ │ │ _ax_flag = False │\r\n╰──────────────────────────────────────────────────────────────────────────────────────────────────╯\r\nValueError: list.remove(x): x not in list\r\n```\r\n\r\nA CI log with multiple such failures can be found here https://github.com/yt-project/yt/runs/2899209479?check_suite_focus=true\r\n\r\n\r\n**Expected outcome**\r\n\r\nThe script is supposed to output a file named \"ParticleData_Projection_z_density.png\".\r\nIt works fine with matplotlib 3.4.0, and I was able to identify (git bisect) the breaking commit in matplotilb: 146856b03e85aa4b1becdd89fe1628f98fed2a05\r\n\r\n**Matplotlib version**\r\n * Operating system: OsX\r\n * Matplotlib version (`import matplotlib; print(matplotlib.__version__)`): 3.4.2.post863+g146856b03\r\n * Matplotlib backend (`print(matplotlib.get_backend())`): \r\n * Python version: I used 3.10.0b2 but I don't believe it is relevant\r\n * Jupyter version (if applicable): \r\n * Other libraries: yt (installed from source, main branch, commit c3054df545b51871ae22ef900a4d0e56cf0f2428) https://github.com/yt-project/yt\r\n\r\nI installed matplotlib with\r\n```\r\npip install git+https://github.com/matplotlib/matplotlib.git\r\n```\r\nand reinstalled on every iteration of my `git bisect` run.","author":{"url":"https://github.com/neutrinoceros","@type":"Person","name":"neutrinoceros"},"datePublished":"2021-06-25T15:17:05.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":9},"url":"https://github.com/20520/matplotlib/issues/20520"}
| 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:8968dcfb-4a80-6e23-b06d-06331633d96e |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | AC28:1258BB:B48F17:F491D0:6A5318FF |
| html-safe-nonce | dfdddb542ae2de604d87e85b3b1894e4ba129a47175b2efbf419677b8661198b |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBQzI4OjEyNThCQjpCNDhGMTc6RjQ5MUQwOjZBNTMxOEZGIiwidmlzaXRvcl9pZCI6IjMxOTU1NjYzMTY5NTUzMTAzMzUiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 09ac0c65298b6598ffb59aa7251ef4ad05ba7d6b5b4bbe7556dd78a2a0c90e54 |
| hovercard-subject-tag | issue:930270911 |
| 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/20520/issue_layout |
| twitter:image | https://opengraph.githubassets.com/65513a8b11bbb5e44bc21cdbca8178f6e8843332e62033182eeffb0f292bf84b/matplotlib/matplotlib/issues/20520 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/65513a8b11bbb5e44bc21cdbca8178f6e8843332e62033182eeffb0f292bf84b/matplotlib/matplotlib/issues/20520 |
| og:image:alt | Bug report Bug summary I found a regression in yt (https://github.com/yt-project/yt) by running our CI against matplotlib's master branch. Code for reproduction Here's a "minimal" script using yt's... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | neutrinoceros |
| 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