Conversation
|
Performance benchmarks:
|
|
Thanks @Holzhauer! As we have a Google Summer of Code contributor working the visualization front end right now so I am going to ask him to take a look as well. But I have no issues with this and am very glad you addressed the Solara initialization issue! |
|
I really like this PR, but as you said there can be a better approach for the size. size or more accurately "s" in the dict arguments contains the sizes of every agents in a list, you can apply similar logic of that of z_order to size as well and use that for zooming. Also pass the z_order to the |
|
@Holzhauer I am good with merging this as is, but could you please resolve the conflicts. If you want to add the Thanks again! |
- add image marker - postpone call of _scatter() in draw* method because limits need to be set earlier - add _get_zoom_factor to achieve correct image size
- add agent attribute 'happy' - add emoticon PNGs - correct Readme.md - adapt agents step method and introduce assign_state - setup use of image markers in app.py - call agent methods in model.py
- refactor masking for markers and images - add agent level transparency for image markers - add agent level zorder for image markers - support agent level image sizes - add transparency to schelling model agent images
f433141 to
c6a0e70
Compare
Sahil-Chhoker
left a comment
There was a problem hiding this comment.
This looks great—everything is concise and clean.
Just one small suggestion: we probably don't need two constants to adjust the size. Using just CORRECTION_FACTOR_MARKER_ZOOM and setting it to 0.01 should do the job well.
That said, it's non-blocking and @tpike3, this PR is good to merge.
|
Thanks @Holzhauer! |

Summary
Enable images as markers for plotting agents and apply the feature to the Schelling model example
Motive
In may cases images are a preferable means to distinguish agents in the visualisation.
Implementation
In
_scatter()it is checked whether the value formarkercontains a valid file resource. If so, an image is created and zoomed (_get_zoom_factor) to the size of a grid cell (it is required to postpone calls of_scatter()indraw*methods because x and y limits need to be set earlier). AnAnnotationBboxis used to display the image on the grid.Usage Examples
The Schelling model was updated to apply image markers (and
AgentPortrayalStyle) depending on agent type and state:(Agents'
stepmethod was changed andassign_stateintroduced. Now the initial number of happy agents is shown correctly in the figure.)Additional Notes
It seems that figure size is adjusted in solara after its initilisation. That's why
CORRECTION_FACTOR_MARKER_ZOOM = 0.6was introduced. There might be a better approach...