René's URL Explorer Experiment


Title: [Bug]: Slider.set_val renders the figure before it notifies its observers, sometimes causing two renders per event · Issue #32526 · matplotlib/matplotlib · GitHub

Open Graph Title: [Bug]: Slider.set_val renders the figure before it notifies its observers, sometimes causing two renders per event · Issue #32526 · matplotlib/matplotlib

X Title: [Bug]: Slider.set_val renders the figure before it notifies its observers, sometimes causing two renders per event · Issue #32526 · matplotlib/matplotlib

Description: Bug summary Slider.set_val renders the figure before it notifies its observers, so a callback that updates other artists causes two renders per event and the first of them is drawn with the previous data. Code for reproduction import mat...

Open Graph Description: Bug summary Slider.set_val renders the figure before it notifies its observers, so a callback that updates other artists causes two renders per event and the first of them is drawn with the previou...

X Description: Bug summary Slider.set_val renders the figure before it notifies its observers, so a callback that updates other artists causes two renders per event and the first of them is drawn with the previou...

Opengraph URL: https://github.com/matplotlib/matplotlib/issues/32526

X: @github

direct link

Domain: github.com

IPv4 address: 140.82.114.3


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[Bug]: Slider.set_val renders the figure before it notifies its observers, sometimes causing two renders per event","articleBody":"### Bug summary\n\n`Slider.set_val` renders the figure before it notifies its observers, so a callback that\nupdates other artists causes two renders per event and the first of them is drawn with the\nprevious data.\n\n### Code for reproduction\n\n```Python\nimport matplotlib\nmatplotlib.use(\"Agg\")\nimport matplotlib.pyplot as plt\nfrom matplotlib.widgets import Slider\n\nfig, (ax, axsl) = plt.subplots(2, 1, height_ratios=[4, 1], figsize=(4, 3))\nfig.subplots_adjust(bottom=0.25)\n(line,) = ax.plot([0, 1], [0, 0])            # an artist the callback will update\nsl = Slider(axsl, \"x\", 0.0, 1.0, valinit=0.0)\n\nndraw = [0]\n_real_draw_idle = fig.canvas.draw_idle\ndef counting_draw_idle(*a, **k):\n    ndraw[0] += 1\n    return _real_draw_idle(*a, **k)\nfig.canvas.draw_idle = counting_draw_idle\n\nat_callback = []\ndef on_change(v):\n    at_callback.append(ndraw[0])             # how many draws already happened\n    line.set_ydata([v, v])\n    fig.canvas.draw_idle()                   # the callback's own draw\nsl.on_changed(on_change)\n\nfor drawon in (True, False):\n    sl.drawon = drawon\n    ndraw[0] = 0\n    at_callback.clear()\n    sl.set_val(0.7)\n    print(f\"drawon={drawon!s:\u003c5}  draws before the callback ran: {at_callback[0]}\"\n          f\"   draws in total: {ndraw[0]}\")\n```\n\n### Actual outcome\n\ndrawon=True   draws before the callback ran: 1   draws in total: 2\ndrawon=False  draws before the callback ran: 0   draws in total: 1\n\n\n### Expected outcome\n\nOne render per event, none of them before the observers run. Either set_val notifies first and draws afterwards, or it leaves drawing to the observers, in which case the docstring should say that callbacks are responsible for the draw_idle.\n\n### Additional information\n\nThe widget draws in `Slider.set_val` (`lib/matplotlib/widgets.py`): it updates the handle and value text, calls `self.ax.get_figure(root=True).canvas.draw_idle()` when `self.drawon`, and only then calls `self._observers.process('changed', val)`.\n\nThe doubled render halves the interactive frame rate of any app built this way, and on a slower backend the stale frame is visible. In the app that prompted this report (four panels redrawn per slider event) one event cost 97 ms, 49 ms of it the wasted render; this was really obvious interactively.\n\n`drawon = False` plus one `draw_idle` in the callback is the workaround and works, but it is not discoverable: `drawon` is not a constructor argument and the `Slider` docstring does not mention it. If changing the ordering risks compatibility, documenting the ordering and the workaround would already remove the trap.\n\nThis was discovered by a DeepSeek v4.1 Flash agent running on Openmath OS, but I verified it independently.\n\n### Operating system\n\nDebian\n\n### Matplotlib Version\n\n3.10.1+dfsg1\n\n### Matplotlib Backend\n\nqtagg (or Agg as in the MWE)\n\n### Python version\n\nPython 3.13.5\n\n### Jupyter version\n\nN/A\n\n### Installation\n\nLinux package manager","author":{"url":"https://github.com/dpthurst","@type":"Person","name":"dpthurst"},"datePublished":"2026-10-23T01:16:16Z","url":"https://github.com/matplotlib/matplotlib/issues/32526"}

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:cd2237bb-ddbb-6e53-be78-a3c78f7c9d18
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idEAE8:3D5080:EE0F41:13D38E0:6B064EE6
html-safe-nonceea81e44f25daa3a55c08d29c4d54107b33dad1d836443770045442f07bc581f0
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFQUU4OjNENTA4MDpFRTBGNDE6MTNEMzhFMDo2QjA2NEVFNiIsInZpc2l0b3JfaWQiOiIyOTQxOTQzNDgxNjE2NDUzMzUwIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmac724df217bec7b01469119d7e6f673f88a336bc55f507ed044cf10931496a8fd9
hovercard-subject-tagissue:5990129036
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/matplotlib/matplotlib/32526/issue_layout
twitter:imagehttps://opengraph.githubassets.com/09af6fb9f8d6876df8962f9cb9639d8c23a7a37e46c83d514a310f7a4139ff23/matplotlib/matplotlib/issues/32526
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/09af6fb9f8d6876df8962f9cb9639d8c23a7a37e46c83d514a310f7a4139ff23/matplotlib/matplotlib/issues/32526
og:image:altBug summary Slider.set_val renders the figure before it notifies its observers, so a callback that updates other artists causes two renders per event and the first of them is drawn with the previou...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamedpthurst
hostnamegithub.com
expected-hostnamegithub.com
None772b6997ca4daa0428dd49a25d76052e765555ae560fe9c88517eb828bbd861e
turbo-cache-controlno-preview
go-importgithub.com/matplotlib/matplotlib git https://github.com/matplotlib/matplotlib.git
octolytics-dimension-user_id215947
octolytics-dimension-user_loginmatplotlib
octolytics-dimension-repository_id1385122
octolytics-dimension-repository_nwomatplotlib/matplotlib
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id1385122
octolytics-dimension-repository_network_root_nwomatplotlib/matplotlib
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
releasef1f9a08f7c769a37f1dfc18ad43d463c222a7eea
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/matplotlib/matplotlib/issues/32526#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmatplotlib%2Fmatplotlib%2Fissues%2F32526
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmatplotlib%2Fmatplotlib%2Fissues%2F32526
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=matplotlib%2Fmatplotlib
Reloadhttps://github.com/matplotlib/matplotlib/issues/32526
Reloadhttps://github.com/matplotlib/matplotlib/issues/32526
Reloadhttps://github.com/matplotlib/matplotlib/issues/32526
matplotlibhttps://github.com/matplotlib
matplotlibhttps://github.com/matplotlib/matplotlib
Codehttps://github.com/matplotlib/matplotlib
Issues1k (1k)https://github.com/matplotlib/matplotlib/issues
Pull requests430 (430)https://github.com/matplotlib/matplotlib/pulls
Actionshttps://github.com/matplotlib/matplotlib/actions
Projectshttps://github.com/matplotlib/matplotlib/projects
Wikihttps://github.com/matplotlib/matplotlib/wiki
Security and qualityhttps://github.com/matplotlib/matplotlib/security
Insightshttps://github.com/matplotlib/matplotlib/insights
https://github.com/matplotlib/matplotlib
New issuehttps://github.com/login?return_to=https://github.com/matplotlib/matplotlib/issues/32526
New issuehttps://github.com/login?return_to=https://github.com/matplotlib/matplotlib/issues/32526
#32587https://github.com/matplotlib/matplotlib/pull/32587
[Bug]: Slider.set_val renders the figure before it notifies its observers, sometimes causing two renders per eventhttps://github.com/matplotlib/matplotlib/issues/32526#top
#32587https://github.com/matplotlib/matplotlib/pull/32587
first-contributionhttps://github.com/matplotlib/matplotlib/issues?q=state%3Aopen%20label%3A%22first-contribution%22
topic: widgets/UIhttps://github.com/matplotlib/matplotlib/issues?q=state%3Aopen%20label%3A%22topic%3A%20widgets%2FUI%22
https://github.com/dpthurst
dpthursthttps://github.com/dpthurst
on Oct 23, 2026https://github.com/matplotlib/matplotlib/issues/32526#issue-5990129036
github-actionshttps://github.com/apps/github-actions
first-contributionhttps://github.com/matplotlib/matplotlib/issues?q=state%3Aopen%20label%3A%22first-contribution%22
on Oct 23, 2026https://github.com/matplotlib/matplotlib/issues/32526#event-34008734489
iccirhttps://github.com/iccir
topic: widgets/UIhttps://github.com/matplotlib/matplotlib/issues?q=state%3Aopen%20label%3A%22topic%3A%20widgets%2FUI%22
on Oct 23, 2026https://github.com/matplotlib/matplotlib/issues/32526#event-34013262455
https://github.com/Rudra-G-23
Rudra-G-23https://github.com/Rudra-G-23
on Nov 10, 2026https://github.com/matplotlib/matplotlib/issues/32526#issuecomment-6757634027
https://github.com/huzaifarahman13
huzaifarahman13https://github.com/huzaifarahman13
on Nov 10, 2026https://github.com/matplotlib/matplotlib/issues/32526#issuecomment-6765092688
#32587https://github.com/matplotlib/matplotlib/pull/32587
Sign up for freehttps://github.com/signup?return_to=https://github.com/matplotlib/matplotlib/issues/32526
Sign in to commenthttps://github.com/login?return_to=https://github.com/matplotlib/matplotlib/issues/32526
first-contributionhttps://github.com/matplotlib/matplotlib/issues?q=state%3Aopen%20label%3A%22first-contribution%22
topic: widgets/UIhttps://github.com/matplotlib/matplotlib/issues?q=state%3Aopen%20label%3A%22topic%3A%20widgets%2FUI%22
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Response headers:
Servergithub.com
Content-Typetext/html; charset=utf-8
Cache-Controlmax-age=0, private, must-revalidate

Viewport: width=device-width


URLs of crawlers that visited me.