Skip to content

Commit

Permalink
Matplotlib refactor (#2430)
Browse files Browse the repository at this point in the history
  • Loading branch information
quaquel authored Oct 30, 2024
1 parent aaf9026 commit 92054d7
Show file tree
Hide file tree
Showing 17 changed files with 911 additions and 300 deletions.
19 changes: 19 additions & 0 deletions docs/apis/visualization.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,22 @@ For a detailed tutorial, please refer to our [Visualization Tutorial](../tutoria
:undoc-members:
:show-inheritance:
```


## Matplotlib-based components

```{eval-rst}
.. automodule:: mesa.visualization.components.matplotlib
:members:
:undoc-members:
:show-inheritance:
```

## Altair-based components

```{eval-rst}
.. automodule:: mesa.visualization.components.altair
:members:
:undoc-members:
:show-inheritance:
```
4 changes: 2 additions & 2 deletions docs/migration_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -268,9 +268,9 @@ from mesa.experimental import SolaraViz
SolaraViz(model_cls, model_params, agent_portrayal=agent_portrayal)

# new
from mesa.visualization import SolaraViz, make_space_matplotlib
from mesa.visualization import SolaraViz, make_space_component

SolaraViz(model, components=[make_space_matplotlib(agent_portrayal)])
SolaraViz(model, components=[make_space_component(agent_portrayal)])
```

#### Plotting "measures"
Expand Down
6 changes: 4 additions & 2 deletions docs/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -168,11 +168,13 @@ 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_matplotlib, make_plot_measure
from mesa.visualization import SolaraViz, make_space_component, make_plot_measure


def agent_portrayal(agent):
return {"color": "blue", "size": 50}


model_params = {
"N": {
"type": "SliderInt",
Expand All @@ -187,7 +189,7 @@ model_params = {
page = SolaraViz(
MyModel,
[
make_space_matplotlib(agent_portrayal),
make_space_component(agent_portrayal),
make_plot_measure("mean_age")
],
model_params=model_params
Expand Down
Loading

0 comments on commit 92054d7

Please sign in to comment.