Skip to content

Pass portrayal size and alpha to scatter in draw_space - #4028

Merged
quaquel merged 2 commits into
mesa:mainfrom
AshNicolus:fix/draw-space-size-alpha
Nov 7, 2026
Merged

quaquel merged 2 commits into
mesa:mainfrom
AshNicolus:fix/draw-space-size-alpha

Conversation

@AshNicolus

Copy link
Copy Markdown
Contributor

Pre-PR Checklist

  • This PR is a bug fix, not a new feature or enhancement.

Summary

draw_space ignored the size and alpha set in AgentPortrayalStyle. Every agent was drawn at the default size and fully opaque.

Bug / Issue

Fixes #4027.

_scatter pops s and alpha out of the arguments since #2799 (image markers). The image branch uses them, but the ordinary ax.scatter call then never gets them.

AgentPortrayalStyle(size=200, alpha=0.3) main this PR
plotted sizes [36.] [200 200 200]
plotted alpha None [0.3 0.3 0.3]

Implementation

_scatter now reads s and alpha instead of popping them, the same way MatplotlibBackend already does. The image marker branch is unchanged.

Testing

  • Added test_draw_orthogonal_grid_uses_size_and_alpha, which checks the sizes and alpha on the plotted collection. It fails on main and passes here.
  • Full suite passes with pytest tests/ -Werror (1022 passed), and ruff is clean.

Additional Notes

Only the legacy draw_space path was affected. SpaceRenderer with the matplotlib backend already handled this correctly.

_scatter popped s and alpha out of the arguments, which the image marker
branch needs, but ordinary markers then never got them, so every agent was
drawn at the default size and fully opaque. Read them without popping, as
MatplotlibBackend already does.
@github-actions github-actions Bot added testing Release notes label visualization labels Nov 1, 2026
@quaquel quaquel added the backport-candidate PRs we might want to backport to an earlier branch label Nov 7, 2026
@quaquel
quaquel merged commit 7728f16 into mesa:main Nov 7, 2026
17 checks passed
EwoutH pushed a commit that referenced this pull request Nov 22, 2026
_scatter popped s and alpha out of the arguments, which the image marker
branch needs, but ordinary markers then never got them, so every agent was
drawn at the default size and fully opaque. Read them without popping, as
MatplotlibBackend already does.

(cherry picked from commit 7728f16)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-candidate PRs we might want to backport to an earlier branch testing Release notes label visualization

Projects

None yet

Development

Successfully merging this pull request may close these issues.

draw_space ignores the portrayal's size and alpha

2 participants