Title: [Bug]: AttributeError: 'NoneType' object has no attribute 'rowspan' with mpl >=3.7 · Issue #25538 · matplotlib/matplotlib · GitHub
Open Graph Title: [Bug]: AttributeError: 'NoneType' object has no attribute 'rowspan' with mpl >=3.7 · Issue #25538 · matplotlib/matplotlib
X Title: [Bug]: AttributeError: 'NoneType' object has no attribute 'rowspan' with mpl >=3.7 · Issue #25538 · matplotlib/matplotlib
Description: Bug summary With mpl <3.7 this code works the code snippet below works but it is broken in 3.7.0 and 3.7.1. The odd thing is that if I move the colorbar to the last line or if I don't use pandas to the the C plotting it works just fine. ...
Open Graph Description: Bug summary With mpl <3.7 this code works the code snippet below works but it is broken in 3.7.0 and 3.7.1. The odd thing is that if I move the colorbar to the last line or if I don't use pandas to...
X Description: Bug summary With mpl <3.7 this code works the code snippet below works but it is broken in 3.7.0 and 3.7.1. The odd thing is that if I move the colorbar to the last line or if I don't use pa...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/25538
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[Bug]: AttributeError: 'NoneType' object has no attribute 'rowspan' with mpl \u003e=3.7","articleBody":"### Bug summary\n\nWith mpl \u003c3.7 this code works the code snippet below works but it is broken in 3.7.0 and 3.7.1. The odd thing is that if I move the colorbar to the last line or if I don't use pandas to the the `C` plotting it works just fine. I guess there is a bad interaction somewhere that is messing up with the subplots.\n\n### Code for reproduction\n\n```python\nimport matplotlib.pyplot as plt\r\nimport pandas as pd\r\n\r\nfig = plt.figure()\r\n\r\naxes = fig.subplot_mosaic(\r\n \"\"\"\r\n AB\r\n CC\r\n \"\"\"\r\n)\r\n\r\nx = [1, 2, 3]\r\ny = [1, 2, 3]\r\n\r\ncs0 = axes[\"A\"].scatter(x, y)\r\ncs1 = axes[\"B\"].scatter(x, y)\r\n\r\nfig.colorbar(cs0, ax=[axes[\"A\"], axes[\"B\"]], location=\"right\")\r\naxes[\"C\"].plot(x)\r\npd.DataFrame(x).plot(ax=axes[\"C\"])\n```\n\n\n### Actual outcome\n\n```\r\nAttributeError Traceback (most recent call last)\r\nCell In[10], line 21\r\n 19 fig.colorbar(cs0, ax=[axes[\"A\"], axes[\"B\"]], location=\"right\")\r\n 20 axes[\"C\"].plot(x)\r\n---\u003e 21 pd.DataFrame(x).plot(ax=axes[\"C\"])\r\n 22 # fig.colorbar(cs0, ax=[axes[\"A\"], axes[\"B\"]], location=\"right\")\r\n\r\nFile ~/micromamba/envs/TEST/lib/python3.11/site-packages/pandas/plotting/_core.py:1000, in PlotAccessor.__call__(self, *args, **kwargs)\r\n 997 label_name = label_kw or data.columns\r\n 998 data.columns = label_name\r\n-\u003e 1000 return plot_backend.plot(data, kind=kind, **kwargs)\r\n\r\nFile ~/micromamba/envs/TEST/lib/python3.11/site-packages/pandas/plotting/_matplotlib/__init__.py:71, in plot(data, kind, **kwargs)\r\n 69 kwargs[\"ax\"] = getattr(ax, \"left_ax\", ax)\r\n 70 plot_obj = PLOT_CLASSES[kind](data, **kwargs)\r\n---\u003e 71 plot_obj.generate()\r\n 72 plot_obj.draw()\r\n 73 return plot_obj.result\r\n\r\nFile ~/micromamba/envs/TEST/lib/python3.11/site-packages/pandas/plotting/_matplotlib/core.py:455, in MPLPlot.generate(self)\r\n 453 self._add_table()\r\n 454 self._make_legend()\r\n--\u003e 455 self._adorn_subplots()\r\n 457 for ax in self.axes:\r\n 458 self._post_plot_logic_common(ax, self.data)\r\n\r\nFile ~/micromamba/envs/TEST/lib/python3.11/site-packages/pandas/plotting/_matplotlib/core.py:679, in MPLPlot._adorn_subplots(self)\r\n 677 all_axes = self._get_subplots()\r\n 678 nrows, ncols = self._get_axes_layout()\r\n--\u003e 679 handle_shared_axes(\r\n 680 axarr=all_axes,\r\n 681 nplots=len(all_axes),\r\n 682 naxes=nrows * ncols,\r\n 683 nrows=nrows,\r\n 684 ncols=ncols,\r\n 685 sharex=self.sharex,\r\n 686 sharey=self.sharey,\r\n 687 )\r\n 689 for ax in self.axes:\r\n 690 ax = getattr(ax, \"right_ax\", ax)\r\n\r\nFile ~/micromamba/envs/TEST/lib/python3.11/site-packages/pandas/plotting/_matplotlib/tools.py:410, in handle_shared_axes(axarr, nplots, naxes, nrows, ncols, sharex, sharey)\r\n 408 layout = np.zeros((nrows + 1, ncols + 1), dtype=np.bool_)\r\n 409 for ax in axarr:\r\n--\u003e 410 layout[row_num(ax), col_num(ax)] = ax.get_visible()\r\n 412 for ax in axarr:\r\n 413 # only the last row of subplots should get x labels -\u003e all\r\n 414 # other off layout handles the case that the subplot is\r\n 415 # the last in the column, because below is no subplot/gap.\r\n 416 if not layout[row_num(ax) + 1, col_num(ax)]:\r\n\r\nFile ~/micromamba/envs/TEST/lib/python3.11/site-packages/pandas/plotting/_matplotlib/tools.py:396, in handle_shared_axes.\u003clocals\u003e.\u003clambda\u003e(x)\r\n 386 def handle_shared_axes(\r\n 387 axarr: Iterable[Axes],\r\n 388 nplots: int,\r\n (...)\r\n 393 sharey: bool,\r\n 394 ):\r\n 395 if nplots \u003e 1:\r\n--\u003e 396 row_num = lambda x: x.get_subplotspec().rowspan.start\r\n 397 col_num = lambda x: x.get_subplotspec().colspan.start\r\n 399 if compat.mpl_ge_3_4_0():\r\n\r\nAttributeError: 'NoneType' object has no attribute 'rowspan'\r\n```\n\n### Expected outcome\n\n\n\n### Additional information\n\n_No response_\n\n### Operating system\n\n_No response_\n\n### Matplotlib Version\n\n3.7.0 and 3.7.1\n\n### Matplotlib Backend\n\nmodule://matplotlib_inline.backend_inline\n\n### Python version\n\n3.11\n\n### Jupyter version\n\n6.5.3\n\n### Installation\n\nconda","author":{"url":"https://github.com/ocefpaf","@type":"Person","name":"ocefpaf"},"datePublished":"2023-03-23T18:23:13.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":4},"url":"https://github.com/25538/matplotlib/issues/25538"}
| 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:26287bfa-397a-d3a1-638f-606a6b04ecc2 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B402:C1E1E:E42FDA:132753C:6A5290ED |
| html-safe-nonce | 3082fc9198e96cb3d24f15c694a0e174dde665d51f8dbfede9460194af31099d |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCNDAyOkMxRTFFOkU0MkZEQToxMzI3NTNDOjZBNTI5MEVEIiwidmlzaXRvcl9pZCI6IjY5NjM2NDc2ODgxNjk2NTY1NTciLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 73399be7e181f6e507dbb3bcfefcbcedca37927da194b059687fea0a71e41773 |
| hovercard-subject-tag | issue:1638075419 |
| 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/25538/issue_layout |
| twitter:image | https://opengraph.githubassets.com/55452ffc0e948c417ddd8a044eb49061cb75f6c99eee84d01b0dbf29070d07c4/matplotlib/matplotlib/issues/25538 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/55452ffc0e948c417ddd8a044eb49061cb75f6c99eee84d01b0dbf29070d07c4/matplotlib/matplotlib/issues/25538 |
| og:image:alt | Bug summary With mpl <3.7 this code works the code snippet below works but it is broken in 3.7.0 and 3.7.1. The odd thing is that if I move the colorbar to the last line or if I don't use pandas to... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | ocefpaf |
| 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