Title: [Bug]: LA image mode not working anymore for custom toolbar buttons · Issue #25164 · matplotlib/matplotlib · GitHub
Open Graph Title: [Bug]: LA image mode not working anymore for custom toolbar buttons · Issue #25164 · matplotlib/matplotlib
X Title: [Bug]: LA image mode not working anymore for custom toolbar buttons · Issue #25164 · matplotlib/matplotlib
Description: Bug summary Prior to matplotlib 3.6, I was able to use an icon for a custom tool in the toolbar of a figure which had a LA mode (see attached). Now I can't seem to be able to load it anymore as a custom icon. Code for reproduction import...
Open Graph Description: Bug summary Prior to matplotlib 3.6, I was able to use an icon for a custom tool in the toolbar of a figure which had a LA mode (see attached). Now I can't seem to be able to load it anymore as a c...
X Description: Bug summary Prior to matplotlib 3.6, I was able to use an icon for a custom tool in the toolbar of a figure which had a LA mode (see attached). Now I can't seem to be able to load it anymore as...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/25164
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[Bug]: LA image mode not working anymore for custom toolbar buttons","articleBody":"### Bug summary\n\nPrior to `matplotlib 3.6`, I was able to use an icon for a custom tool in the toolbar of a figure which had a `LA` mode (see attached). Now I can't seem to be able to load it anymore as a custom icon.\r\n\r\n\n\n### Code for reproduction\n\n```python\nimport os\r\n\r\nimport matplotlib\r\nmatplotlib.rcParams[\"toolbar\"] = \"toolmanager\"\r\nimport matplotlib.pyplot as plt\r\nfrom matplotlib.backend_tools import ToolToggleBase\r\n\r\n\r\nclass CustomTool(ToolToggleBase):\r\n image = os.path.join(os.path.dirname(__file__), \"icon.png\")\r\n\r\n\r\nif __name__ == \"__main__\":\r\n fig = plt.figure()\r\n toolmanager = fig.canvas.manager.toolmanager\r\n toolbar = fig.canvas.manager.toolbar\r\n\r\n toolmanager.add_tool(\"custom\", CustomTool)\r\n toolbar.add_tool(\"custom\", \"group\")\n```\n\n\n### Actual outcome\n\n```\r\n/home/[...]/mwe.py:4: UserWarning: Treat the new Tool classes introduced in v1.5 as experimental for now; the API and rcParam may change in future versions.\r\n matplotlib.rcParams[\"toolbar\"] = \"toolmanager\"\r\nTraceback (most recent call last):\r\n File \"/home/[...]/mwe.py\", line 19, in \u003cmodule\u003e\r\n toolbar.add_tool(\"custom\", \"group\")\r\n File \"/home/[...]/lib/python3.10/site-packages/matplotlib/backend_bases.py\", line 3377, in add_tool\r\n self.add_toolitem(tool.name, group, position,\r\n File \"/home/[...]/lib/python3.10/site-packages/matplotlib/backends/_backend_tk.py\", line 957, in add_toolitem\r\n button = NavigationToolbar2Tk._Button(frame, name, image_file, toggle,\r\n File \"/home/[...]/lib/python3.10/site-packages/matplotlib/backends/_backend_tk.py\", line 792, in _Button\r\n NavigationToolbar2Tk._set_image_for_button(self, b)\r\n File \"/home/[...]/lib/python3.10/site-packages/matplotlib/backends/_backend_tk.py\", line 734, in _set_image_for_button\r\n im_alt = _recolor_icon(im, foreground)\r\n File \"/home/[...]/lib/python3.10/site-packages/matplotlib/backends/_backend_tk.py\", line 722, in _recolor_icon\r\n image_data[black_mask, :3] = color\r\nValueError: shape mismatch: value array of shape (3,) could not be broadcast to indexing result of shape (0,2)\r\n```\r\n\n\n### Expected outcome\n\nNo errors should be raised and the icon should be displayed in the toolbar.\n\n### Additional information\n\nDowngrading to `matplotlib v 3.5.3` solves the issue. Don't know why this happens, but icons that have a `RGBA` mode (like the default icons) don't seem to have this problem. The attached icon has a `LA` mode.\n\n### Operating system\n\nUbuntu 22.04\n\n### Matplotlib Version\n\n3.6.3\n\n### Matplotlib Backend\n\nTkAgg\n\n### Python version\n\n3.10.6\n\n### Jupyter version\n\nN/A\n\n### Installation\n\npip","author":{"url":"https://github.com/fgoudreault","@type":"Person","name":"fgoudreault"},"datePublished":"2023-02-06T19:44:46.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/25164/matplotlib/issues/25164"}
| 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:ef5e2b8b-bbd1-0e3d-a9d8-8acc8aecf09d |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B1C8:1A2FA1:A68D45D:AA06558:6A50B52A |
| html-safe-nonce | 7ef07475f65e076098b1407045b1dffd81ed5bcb302055384f249d71714f5e9d |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCMUM4OjFBMkZBMTpBNjhENDVEOkFBMDY1NTg6NkE1MEI1MkEiLCJ2aXNpdG9yX2lkIjoiNTU1MzY2ODI3MjAyMzQ1MDkyMiIsInJlZ2lvbl9lZGdlIjoic2VhIiwicmVnaW9uX3JlbmRlciI6InNlYSJ9 |
| visitor-hmac | 51c70a2209975ea95c2bfb8f370d4452e2172229ac8421b3c17e8d2ac167cf18 |
| hovercard-subject-tag | issue:1573171635 |
| 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/25164/issue_layout |
| twitter:image | https://opengraph.githubassets.com/0d022dc4da0d5c94bced071d0e1d26f2d1937f0c55413e2789e4df669181e2fb/matplotlib/matplotlib/issues/25164 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/0d022dc4da0d5c94bced071d0e1d26f2d1937f0c55413e2789e4df669181e2fb/matplotlib/matplotlib/issues/25164 |
| og:image:alt | Bug summary Prior to matplotlib 3.6, I was able to use an icon for a custom tool in the toolbar of a figure which had a LA mode (see attached). Now I can't seem to be able to load it anymore as a c... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | fgoudreault |
| hostname | github.com |
| expected-hostname | github.com |
| None | 63772747707af4093f0d5fc7aa1bb3bb55f412a9865207c4f421aa34c64cc404 |
| 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 | ded53fe94e3ff1bb4dbf8cc77e285396c92580fb |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width