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

rename make_plot_measure to make_plot_component and add some kwargs #2446

Merged
merged 6 commits into from
Oct 30, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
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
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
32 changes: 16 additions & 16 deletions docs/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -168,31 +168,31 @@ 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):
return {"color": "blue", "size": 50}
return {"color": "blue", "size": 50}


model_params = {
"N": {
"type": "SliderInt",
"value": 50,
"label": "Number of agents:",
"min": 10,
"max": 100,
"step": 1,
}
"N": {
"type": "SliderInt",
quaquel marked this conversation as resolved.
Show resolved Hide resolved
"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")
],
model_params=model_params
MyModel,
[
make_space_component(agent_portrayal),
make_plot_component("mean_age")
],
model_params=model_params
)
page
```
Expand Down
Loading
Loading