Skip to content

Commit

Permalink
rename make_plot_measure to make_plot_component and add some kwargs (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
quaquel authored Oct 30, 2024
1 parent 9de5595 commit 217cb58
Show file tree
Hide file tree
Showing 12 changed files with 140 additions and 213 deletions.
6 changes: 4 additions & 2 deletions docs/migration_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -281,15 +281,17 @@ SolaraViz(model, components=[make_space_component(agent_portrayal)])
# old
from mesa.experimental import SolaraViz


def make_plot(model):
...


SolaraViz(model_cls, model_params, measures=[make_plot, "foo", ["bar", "baz"]])

# new
from mesa.visualization import SolaraViz, make_plot_measure
from mesa.visualization import SolaraViz, make_plot_component

SolaraViz(model, components=[make_plot, make_plot_measure("foo"), make_plot_measure("bar", "baz")])
SolaraViz(model, components=[make_plot, make_plot_component("foo"), make_plot_component("bar", "baz")])
```

#### Plotting text
Expand Down
20 changes: 10 additions & 10 deletions docs/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ The results are returned as a list of dictionaries, which can be easily converte
Mesa now uses a new browser-based visualization system called SolaraViz. This allows for interactive, customizable visualizations of your models. Here's a basic example of how to set up a visualization:

```python
from mesa.visualization import SolaraViz, make_space_component, make_plot_measure
from mesa.visualization import SolaraViz, make_space_component, make_plot_component


def agent_portrayal(agent):
Expand All @@ -177,20 +177,20 @@ def agent_portrayal(agent):

model_params = {
"N": {
"type": "SliderInt",
"value": 50,
"label": "Number of agents:",
"min": 10,
"max": 100,
"step": 1,
}
"type": "SliderInt",
"value": 50,
"label": "Number of agents:",
"min": 10,
"max": 100,
"step": 1,
}
}

page = SolaraViz(
MyModel,
[
make_space_component(agent_portrayal),
make_plot_measure("mean_age")
make_space_component(agent_portrayal),
make_plot_component("mean_age")
],
model_params=model_params
)
Expand Down
Loading

0 comments on commit 217cb58

Please sign in to comment.