More parameter functionality in matplotlib (default) drawer visualization
(screenshots of changes w/ example agent_portrayal functions coming)
Stuff like this is now possible:
def agent_portrayal(cell):
return {
"c": "white" if cell.isAlive else "black",
"s": 45,
"marker": "*",
"edgecolors": "purple",
"linewidths": 0.5,
"alpha": 0.5,
}
- updates necessary docstring
- supports all params in matplotlib's scatter with the exception of
plotnonfinite - manual colormapping to get around restrictions similar to those with 'marker', where a unique colormap cannot usually be provided for each point plotted
- streamlined code for
_split_and_scatterandportray
Performance benchmarks:
| Model | Size | Init time [95% CI] | Run time [95% CI] |
|---|---|---|---|
| Schelling | small | 🔵 +0.0% [-0.4%, +0.4%] | 🔵 +1.6% [+1.2%, +1.9%] |
| Schelling | large | 🔵 +0.9% [+0.1%, +1.7%] | 🔵 +1.5% [-1.5%, +5.6%] |
| WolfSheep | small | 🔵 +0.5% [-0.8%, +1.6%] | 🔵 +0.6% [+0.3%, +0.9%] |
| WolfSheep | large | 🔵 +0.5% [-0.1%, +0.9%] | 🔵 +0.5% [-0.7%, +1.6%] |
| BoidFlockers | small | 🔵 +0.9% [+0.4%, +1.4%] | 🔵 +1.7% [+1.0%, +2.3%] |
| BoidFlockers | large | 🔵 +1.0% [+0.6%, +1.3%] | 🔵 +1.5% [+0.8%, +2.1%] |
Thanks for this PR, sorry none of us got back to you (@projectmesa/maintainers we should be better in this - a full week is quite long).
It looks really useful. We indeed need to discuss how we handle variable names.
I might support going full matplotlib convention. So marker instead of shape, etc.
There is a problem with using Matplotlib nomenclature because Altair's API naming might be different. But it's better to pick either Matplotlib/Altair than to create a separate new naming scheme that nobody is familiar with. I haven't looked at Altair's but I assume the naming would be more modern.
@rmhopkins4 are you still interested in working on this? If so, how can I help?
@EwoutH, while in a perfect world, we hope that @rmhopkins4 hasn't moved on and will gloriously return to this awesomeness to carry the torch, but if they have - I wonder if we should create a tag to recognize incomplete but valuable PRs that might be picked up in the future for completion? (Maybe it takes 2 core contributors to agree on the potential -- so we don't add the tag to every PR.)
Yeah I agree this one is worth getting in. Maybe @Corvince or @rht wants to finish it?
For now we can just add it to the 3.0 milestone.
As soon as #2336 is merged I'm going to try to revive this.
superseded by #2467