Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Viz: Refactor Matplotlib plotting #2430

Merged
merged 77 commits into from
Oct 30, 2024
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
77 commits
Select commit Hold shift + click to select a range
e7d1fee
start
quaquel Oct 23, 2024
bbb0122
ongoin
quaquel Oct 23, 2024
747b98b
Merge remote-tracking branch 'upstream/main' into matplotlib_refactor
quaquel Oct 25, 2024
3616510
Merge remote-tracking branch 'upstream/main' into matplotlib_refactor
quaquel Oct 25, 2024
4197325
creating a mess
quaquel Oct 25, 2024
8e7b6c6
ongoing refactor
quaquel Oct 27, 2024
bdb23cb
Update matplotlib.py
quaquel Oct 27, 2024
9f543da
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 27, 2024
355ab0d
Update matplotlib.py
quaquel Oct 27, 2024
4436072
undo space changes
quaquel Oct 27, 2024
022cfdc
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 27, 2024
a5b52a3
Merge branch 'main' into matplotlib_refactor
quaquel Oct 27, 2024
aad49e2
Delete util.py
quaquel Oct 27, 2024
5c2ddcb
add width and height property to voroinoi
quaquel Oct 27, 2024
327b539
add tests
quaquel Oct 27, 2024
d8a409a
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 27, 2024
c3ca9d7
add mesh to draw_hexgrid
quaquel Oct 27, 2024
519670f
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 27, 2024
80f10bf
remove properties again
quaquel Oct 28, 2024
a30b142
ongoing work
quaquel Oct 28, 2024
f54f52b
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 28, 2024
295b819
ruff fix and update to plot
quaquel Oct 28, 2024
b9ecc22
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 28, 2024
101aad6
make tests work again
quaquel Oct 28, 2024
9477f66
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 28, 2024
9904d25
fix networks
quaquel Oct 28, 2024
15fa02a
correctly update x,y for hexgrids
quaquel Oct 28, 2024
dbeb922
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 28, 2024
669aa0b
correction for how hexgrids are wired
quaquel Oct 28, 2024
1bbe379
simplification of case match structure
quaquel Oct 28, 2024
fc63cf4
update to tests because draw functions take an axes instance as argument
quaquel Oct 28, 2024
8a55816
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 28, 2024
84954fd
fix for failing tests
quaquel Oct 28, 2024
24e3154
move propertlayer drawing out of specific draw_x functions
quaquel Oct 28, 2024
81d90e7
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 28, 2024
36b9623
add tests for and fixes errors in draw_property_layers
quaquel Oct 28, 2024
5c28476
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 28, 2024
0cec04e
Update matplotlib.py
quaquel Oct 28, 2024
b07620f
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 28, 2024
315e7eb
cleanup
quaquel Oct 28, 2024
f685db4
some further cleanup
quaquel Oct 28, 2024
4c727ec
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 28, 2024
c102abb
further annotation of code
quaquel Oct 28, 2024
cad794f
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 28, 2024
dfe15df
minor updates
quaquel Oct 28, 2024
95b963f
Update matplotlib.py
quaquel Oct 28, 2024
d5f69c1
add boolean kwarg to control grid drawing
quaquel Oct 28, 2024
9d2c970
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 28, 2024
aa2110f
Update matplotlib.py
quaquel Oct 28, 2024
cdea051
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 28, 2024
22f57e4
ruff related fix
quaquel Oct 28, 2024
511214e
Update app.py
quaquel Oct 28, 2024
0fa5c1f
make ax optional
quaquel Oct 29, 2024
7914328
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 29, 2024
d9db041
add a draw_space function and improve typing
quaquel Oct 29, 2024
f9adfba
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 29, 2024
aad0a8c
Update matplotlib.py
quaquel Oct 29, 2024
6d7fae8
reorganization of file and warning added for ignored fields
quaquel Oct 29, 2024
de5ec29
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 29, 2024
e6938c1
further doc updates
quaquel Oct 29, 2024
2925106
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 29, 2024
0ce0c7c
Update test_solara_viz.py
quaquel Oct 29, 2024
9282bfe
ruff related fixes
quaquel Oct 29, 2024
d5b8ec6
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 29, 2024
ce2a8de
update example
quaquel Oct 29, 2024
9efaa99
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 29, 2024
3a753bb
ensure visualization.components is included in the docs
quaquel Oct 29, 2024
27e5e26
add zorder in and update example
quaquel Oct 29, 2024
f36fbbc
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 29, 2024
9c2e8cd
docstring fixes
quaquel Oct 29, 2024
cdbea6e
cleanup
quaquel Oct 29, 2024
f371ef0
rename to make_space_component, return ax and update docs
quaquel Oct 29, 2024
eabcbab
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 29, 2024
40cc9e4
Update visualization_tutorial.ipynb
quaquel Oct 29, 2024
8c3d928
docs
quaquel Oct 29, 2024
642ba12
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 29, 2024
10c24c9
Update mesa/examples/basic/conways_game_of_life/app.py
quaquel Oct 30, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 20 additions & 11 deletions mesa/examples/advanced/wolf_sheep/app.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
import os.path
import sys

Check warning on line 2 in mesa/examples/advanced/wolf_sheep/app.py

View check run for this annotation

Codecov / codecov/patch

mesa/examples/advanced/wolf_sheep/app.py#L1-L2

Added lines #L1 - L2 were not covered by tests

sys.path.insert(

Check warning on line 4 in mesa/examples/advanced/wolf_sheep/app.py

View check run for this annotation

Codecov / codecov/patch

mesa/examples/advanced/wolf_sheep/app.py#L4

Added line #L4 was not covered by tests
0, os.path.abspath(os.path.join(os.path.dirname(__file__), "../../../../"))
)


from mesa.examples.advanced.wolf_sheep.agents import GrassPatch, Sheep, Wolf
from mesa.examples.advanced.wolf_sheep.model import WolfSheep
from mesa.visualization import (
Expand All @@ -16,24 +24,25 @@
return

portrayal = {
"size": 25,
"shape": "s", # square marker
"s": 25,
}

if isinstance(agent, Wolf):
portrayal["color"] = WOLF_COLOR
portrayal["Layer"] = 3
portrayal["c"] = "tab:orange"
portrayal["marker"] = "o"

Check warning on line 32 in mesa/examples/advanced/wolf_sheep/app.py

View check run for this annotation

Codecov / codecov/patch

mesa/examples/advanced/wolf_sheep/app.py#L31-L32

Added lines #L31 - L32 were not covered by tests
elif isinstance(agent, Sheep):
portrayal["color"] = SHEEP_COLOR
portrayal["Layer"] = 2
portrayal["c"] = "tab:blue"
portrayal["zorder"] = 2
portrayal["marker"] = "o"

Check warning on line 36 in mesa/examples/advanced/wolf_sheep/app.py

View check run for this annotation

Codecov / codecov/patch

mesa/examples/advanced/wolf_sheep/app.py#L34-L36

Added lines #L34 - L36 were not covered by tests
elif isinstance(agent, GrassPatch):
if agent.fully_grown:
portrayal["color"] = "#00FF00"
portrayal["c"] = "tab:green"

Check warning on line 39 in mesa/examples/advanced/wolf_sheep/app.py

View check run for this annotation

Codecov / codecov/patch

mesa/examples/advanced/wolf_sheep/app.py#L39

Added line #L39 was not covered by tests
else:
portrayal["color"] = "#84e184"
# portrayal["shape"] = "rect"
portrayal["c"] = "tab:brown"
portrayal["marker"] = "s"

Check warning on line 42 in mesa/examples/advanced/wolf_sheep/app.py

View check run for this annotation

Codecov / codecov/patch

mesa/examples/advanced/wolf_sheep/app.py#L41-L42

Added lines #L41 - L42 were not covered by tests
# portrayal["Filled"] = "true"
portrayal["Layer"] = 1
portrayal["zorder"] = 1
portrayal["s"] = 75

Check warning on line 45 in mesa/examples/advanced/wolf_sheep/app.py

View check run for this annotation

Codecov / codecov/patch

mesa/examples/advanced/wolf_sheep/app.py#L44-L45

Added lines #L44 - L45 were not covered by tests

return portrayal

Expand Down Expand Up @@ -65,7 +74,7 @@
space_component = make_space_matplotlib(wolf_sheep_portrayal)
lineplot_component = make_plot_measure(["Wolves", "Sheep", "Grass"])

model = WolfSheep()
model = WolfSheep(grass=True)

Check warning on line 77 in mesa/examples/advanced/wolf_sheep/app.py

View check run for this annotation

Codecov / codecov/patch

mesa/examples/advanced/wolf_sheep/app.py#L77

Added line #L77 was not covered by tests


page = SolaraViz(
Expand Down
Loading
Loading