mesa icon indicating copy to clipboard operation
mesa copied to clipboard

More parameter functionality in matplotlib (default) drawer visualization

Open rmhopkins4 opened this issue 1 year ago • 7 comments

(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,
    }

image

  • 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_scatter and portray

rmhopkins4 avatar Aug 23 '24 13:08 rmhopkins4

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%]

github-actions[bot] avatar Aug 23 '24 13:08 github-actions[bot]

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.

EwoutH avatar Aug 29 '24 09:08 EwoutH

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.

rht avatar Aug 29 '24 10:08 rht

@rmhopkins4 are you still interested in working on this? If so, how can I help?

EwoutH avatar Sep 20 '24 08:09 EwoutH

@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.)

jackiekazil avatar Sep 23 '24 03:09 jackiekazil

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.

EwoutH avatar Sep 23 '24 03:09 EwoutH

As soon as #2336 is merged I'm going to try to revive this.

EwoutH avatar Oct 04 '24 08:10 EwoutH

superseded by #2467

quaquel avatar Nov 08 '24 13:11 quaquel