Update SpaceRenderer API in Tutorials 4, 5, and 6#3231
Merged
Conversation
Migrates the visualization tutorials to use the new SpaceRenderer API (setup_structure, setup_agents, and render() without arguments). This resolves deprecation warnings and aligns the documentation with the latest visualization workflow. - docs/tutorials/4_visualization_basic.ipynb: Update to setup_agents() - docs/tutorials/5_visualization_dynamic_agents.ipynb: Update to setup_agents() - docs/tutorials/6_visualization_rendering_with_space_renderer.ipynb: Update to setup_* methods and Markdown descriptions.
quaquel
approved these changes
Feb 4, 2026
This was referenced Feb 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR migrates several Mesa tutorials (4, 5, and 6) to the new
SpaceRendererAPI. It resolves deprecation warnings by replacing the olderdraw_*methods and parameterizedrender()calls with the recommendedsetup_*methods and a parameterlessrender()callBug / Issue
The tutorials were still using the deprecated visualization API. Specifically:
draw_structure()anddraw_agents()instead of the newsetup_structure()andsetup_agents()methods.They passed portrayal arguments directly to .render(), which is now deprecated in favor of a "setup then render" workflow.PendingDeprecationWarningandFutureWarningfor users following the tutorials and inconsistent teaching of the library's best practices.Implementation
Updated the following Jupyter notebooks:
.setup_agents(agent_portrayal).render().docs/tutorials/5_visualization_dynamic_agents.ipynb:.setup_agents(agent_portrayal).render().docs/tutorials/6_visualization_rendering_with_space_renderer.ipynb:MatplotlibandAltairexamples to the multi-step pattern:setup_structure(...),setup_agents(...), and thenrender().Markdown Cells: Updated all text references to reflect the method name changes (changingdraw_structure()tosetup_structure()anddraw_agents()tosetup_agents()) to ensure instructional consistency.Testing
mesa/visualization/space_renderer.py.If you're fixing the visualisation, add before/after screenshots. -->
Additional Notes
This migration ensures that the "setup then render" paradigm is taught consistently across all core spatial visualization tutorials.
Closes #3228