Title: [Bug]: RangeSlider.set_val does not move the slider (only poly and value) · Issue #22706 · matplotlib/matplotlib · GitHub
Open Graph Title: [Bug]: RangeSlider.set_val does not move the slider (only poly and value) · Issue #22706 · matplotlib/matplotlib
X Title: [Bug]: RangeSlider.set_val does not move the slider (only poly and value) · Issue #22706 · matplotlib/matplotlib
Description: Bug summary When I call RangeSlider.set_val([0.0,0.1]) It changes only the blue poly object and the range value on the right side of the slider not the dot: Code for reproduction import numpy as np import matplotlib.pyplot as plt from ma...
Open Graph Description: Bug summary When I call RangeSlider.set_val([0.0,0.1]) It changes only the blue poly object and the range value on the right side of the slider not the dot: Code for reproduction import numpy as np...
X Description: Bug summary When I call RangeSlider.set_val([0.0,0.1]) It changes only the blue poly object and the range value on the right side of the slider not the dot: Code for reproduction import numpy as np...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/22706
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[Bug]: RangeSlider.set_val does not move the slider (only poly and value)","articleBody":"### Bug summary\n\nWhen I call `RangeSlider.set_val([0.0,0.1])`\r\nIt changes only the blue poly object and the range value on the right side of the slider not the dot:\r\n\r\n\r\n\n\n### Code for reproduction\n\n```python\nimport numpy as np\r\nimport matplotlib.pyplot as plt\r\nfrom matplotlib.widgets import RangeSlider\r\n\r\n# generate a fake image\r\nnp.random.seed(19680801)\r\nN = 128\r\nimg = np.random.randn(N, N)\r\n\r\nfig, axs = plt.subplots(1, 2, figsize=(10, 5))\r\nfig.subplots_adjust(bottom=0.25)\r\n\r\nim = axs[0].imshow(img)\r\naxs[1].hist(img.flatten(), bins='auto')\r\naxs[1].set_title('Histogram of pixel intensities')\r\n\r\n# Create the RangeSlider\r\nslider_ax = fig.add_axes([0.20, 0.1, 0.60, 0.03])\r\nslider = RangeSlider(slider_ax, \"Threshold\", img.min(), img.max(),valinit=[0.0,1])\r\n\r\n# Create the Vertical lines on the histogram\r\nlower_limit_line = axs[1].axvline(slider.val[0], color='k')\r\nupper_limit_line = axs[1].axvline(slider.val[1], color='k')\r\n\r\n\r\ndef update(val):\r\n # The val passed to a callback by the RangeSlider will\r\n # be a tuple of (min, max)\r\n\r\n # Update the image's colormap\r\n im.norm.vmin = val[0]\r\n im.norm.vmax = val[1]\r\n\r\n # Update the position of the vertical lines\r\n lower_limit_line.set_xdata([val[0], val[0]])\r\n upper_limit_line.set_xdata([val[1], val[1]])\r\n\r\n # Redraw the figure to ensure it updates\r\n fig.canvas.draw_idle()\r\n\r\nslider.set_val([0.0,5])\r\nslider.on_changed(update)\r\nplt.show()\n```\n\n\n### Actual outcome\n\n I does not move the slider\r\n\r\n\r\n\n\n### Expected outcome\n\n It should move the slider\n\n### Additional information\n\n_No response_\n\n### Operating system\n\nOSX\n\n### Matplotlib Version\n\n3.5.1\n\n### Matplotlib Backend\n\n_No response_\n\n### Python version\n\n3.8\n\n### Jupyter version\n\n_No response_\n\n### Installation\n\npip","author":{"url":"https://github.com/vpicouet","@type":"Person","name":"vpicouet"},"datePublished":"2022-03-25T22:04:34.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":5},"url":"https://github.com/22706/matplotlib/issues/22706"}
| 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:9711cc75-e2bf-2ca2-7d93-f4a2f7b55bff |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | BF6C:274C16:2CC96D:3BA726:6A522812 |
| html-safe-nonce | e3ef0360e0b7f908b9506bacb7ee2cb724026f6ab9a3275ce4bb34a597846327 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCRjZDOjI3NEMxNjoyQ0M5NkQ6M0JBNzI2OjZBNTIyODEyIiwidmlzaXRvcl9pZCI6Ijc4NjUyMDMzNzQ0OTg4Nzc2MyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | f33d20d4b60ec3559406c6e7b1da3d9aaab0a8eb57a0d2821d4f432a153952bb |
| hovercard-subject-tag | issue:1181312470 |
| 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/22706/issue_layout |
| twitter:image | https://opengraph.githubassets.com/a313b002bb32592a9b01d4be9b0da606adbe675615fcf269887a390df89347c0/matplotlib/matplotlib/issues/22706 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/a313b002bb32592a9b01d4be9b0da606adbe675615fcf269887a390df89347c0/matplotlib/matplotlib/issues/22706 |
| og:image:alt | Bug summary When I call RangeSlider.set_val([0.0,0.1]) It changes only the blue poly object and the range value on the right side of the slider not the dot: Code for reproduction import numpy as np... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | vpicouet |
| 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