-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Closed
Description
The Visualize PropertyLayers PR (#2336) added a new internal function _get_agent_data to the visualization/components/matplotlib.py module. This function gathers data from the agent_portrayal dict, while handling synonyms and ommitted data.
Currently only drawing the grid uses it, but ideally, all spaces would use it.
A concrete example, is that currently if you omit "size" in your agent_portrayal dict, you get this non-obvious error:
File "C:\Users\Ewout\Documents\GitHub\mesa\mesa\visualization\components\matplotlib.py", line 67, in SpaceMatplotlib
_draw_discrete_space_grid(space, space_ax, agent_portrayal)
File "C:\Users\Ewout\Documents\GitHub\mesa\mesa\visualization\components\matplotlib.py", line 335, in _draw_discrete_space_grid
space_ax.scatter(**portray(space))
File "C:\Users\Ewout\.virtualenvs\Py312\Lib\site-packages\matplotlib\__init__.py", line 1473, in inner
return func(
^^^^^
File "C:\Users\Ewout\.virtualenvs\Py312\Lib\site-packages\matplotlib\axes\_axes.py", line 4796, in scatter
raise ValueError(
ValueError: s must be a scalar, or float array-like with the same size as x and y
Adding something like
portrayal = {
"s": 25,
...does not fix the issue, since you need to add "size", since we internally translate that.
_get_agent_data does not only also check for "s", but it also includes default values for when it's omitted.
This issue is probably related to:
Metadata
Metadata
Assignees
Labels
No labels