Title: [Bug]: Hexbin hbar and vbar not updating correctly on changed · Issue #28633 · matplotlib/matplotlib · GitHub
Open Graph Title: [Bug]: Hexbin hbar and vbar not updating correctly on changed · Issue #28633 · matplotlib/matplotlib
X Title: [Bug]: Hexbin hbar and vbar not updating correctly on changed · Issue #28633 · matplotlib/matplotlib
Description: Bug summary A hexbar with marginals=True has independent norms on the hexbins and the hbar and vbar unless vmin/vmax is set manually. However, if the a changed signal is called, the behavior changes, and vmin/vmax is updated on the hbar ...
Open Graph Description: Bug summary A hexbar with marginals=True has independent norms on the hexbins and the hbar and vbar unless vmin/vmax is set manually. However, if the a changed signal is called, the behavior change...
X Description: Bug summary A hexbar with marginals=True has independent norms on the hexbins and the hbar and vbar unless vmin/vmax is set manually. However, if the a changed signal is called, the behavior change...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/28633
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[Bug]: Hexbin hbar and vbar not updating correctly on changed","articleBody":"### Bug summary\n\nA hexbar with `marginals=True` has independent norms on the hexbins and the hbar and vbar unless vmin/vmax is set manually. \r\nHowever, if the a changed signal is called, the behavior changes, and vmin/vmax is updated on the hbar and vbar to be equal to the vmin/vmax on main.\r\n\r\nAditionally, there is a bug so that the \n\n### Code for reproduction\n\n```Python\n# based on test_axes.py -- test_hexbin_linear()\r\nimport matplotlib.pyplot as plt\r\nimport numpy as np\r\nnp.random.seed(19680801)\r\nn = 100000\r\nx = np.random.standard_normal(n)\r\ny = 2.0 + 3.0 * x + 4.0 * np.random.standard_normal(n)\r\n\r\nfig, axes = plt.subplots(2, 1, figsize=(9, 9))\r\ncs = axes[0].hexbin(x, y, gridsize=(10, 5), marginals=True,\r\n reduce_C_function=np.sum)\r\n\r\nfig.colorbar(cs.hbar).set_label('hbar')\r\nfig.colorbar(cs.vbar).set_label('vbar')\r\nfig.colorbar(cs).set_label('main')\r\n\r\n\r\ncs = axes[1].hexbin(x, y, gridsize=(10, 5), marginals=True,\r\n reduce_C_function=np.sum)\r\ncs.set_cmap('rainbow')\r\n\r\nfig.colorbar(cs.hbar).set_label('hbar')\r\nfig.colorbar(cs.vbar).set_label('vbar')\r\nfig.colorbar(cs).set_label('main')\n```\n\n\n### Actual outcome\n\n\r\nOnly two of three colorbars change, and the limits are changed on the vbar.\n\n### Expected outcome\n\nAll three colorbars in the lower plot should change, but the limits should not update\n\n### Additional information\n\nThis bug came up as I was looking at this code in relation to the new `data→color` pipeline suggested in #28428. \r\nI can find no report on this bug by actual users, so I don't think it needs a quick resolution.\r\n* If the new `data→color` pipeline discussed in #28428 is approved, this bug will be resolved as part of this.\r\n* If the new `data→color` pipeline is not approved, a small bugfix for this issue could be made (good first issue?)\r\n\r\n\r\nThe relevant code is in _axes.py, in the function `hexbin()` which includes\r\n```py\r\n def on_changed(collection):\r\n collection.hbar.set_cmap(collection.get_cmap())\r\n collection.hbar.set_cmap(collection.get_cmap())\r\n collection.vbar.set_clim(collection.get_clim())\r\n collection.vbar.set_clim(collection.get_clim())\r\n collection.callbacks.connect('changed', on_changed)\r\n```\r\nwhere `hbar` and `vbar` is used in the wrong order.\r\nHowever, only updating this will not resolve the issue where changing the colorbar changes the limits on the hbar and vbar in the case where these limits have not been set.\n\n### Operating system\n\n_No response_\n\n### Matplotlib Version\n\n3.8.2, matplotlib-dev\n\n### Matplotlib Backend\n\n_No response_\n\n### Python version\n\n_No response_\n\n### Jupyter version\n\n_No response_\n\n### Installation\n\ngit checkout","author":{"url":"https://github.com/trygvrad","@type":"Person","name":"trygvrad"},"datePublished":"2024-08-01T09:34:38.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/28633/matplotlib/issues/28633"}
| 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:f73afd54-b9db-8872-e51b-9a29bdc06394 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B1D4:1ED62B:6A532F:8F8DF4:6A51EFA1 |
| html-safe-nonce | a54bc0c3c435fea2f19777c6d98a44d8b06ca2cb818fbb907ca017a48f240a08 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCMUQ0OjFFRDYyQjo2QTUzMkY6OEY4REY0OjZBNTFFRkExIiwidmlzaXRvcl9pZCI6IjQ3NTkyODQxMTc1MjY0MDkxMjEiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 80382efec159a0bf0ede310656d3e933a21994b9acf15e3f4cf1f67e7bf8bbd0 |
| hovercard-subject-tag | issue:2441976572 |
| 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/28633/issue_layout |
| twitter:image | https://opengraph.githubassets.com/6a64e818a47928c5de4cf52769fd915226041ed956a3ead0d97302264fcfa525/matplotlib/matplotlib/issues/28633 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/6a64e818a47928c5de4cf52769fd915226041ed956a3ead0d97302264fcfa525/matplotlib/matplotlib/issues/28633 |
| og:image:alt | Bug summary A hexbar with marginals=True has independent norms on the hexbins and the hbar and vbar unless vmin/vmax is set manually. However, if the a changed signal is called, the behavior change... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | trygvrad |
| 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 | canary-2 |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width