Skip to content

Commit ba6d2d5

Browse files
committed
add a note and fix histogram code
1 parent 9baee14 commit ba6d2d5

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

docs/tutorials/visualization_tutorial.ipynb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,9 @@
194194
"\n",
195195
"If the visualization elements provided by Mesa aren't enough for you, you can build your own and plug them into the model server.\n",
196196
"\n",
197-
"For this example, let's build a simple histogram visualization, which can count the number of agents with each value of wealth."
197+
"For this example, let's build a simple histogram visualization, which can count the number of agents with each value of wealth.\n",
198+
"\n",
199+
"**Note:** Due to the way solara works we need to trigger an update whenever the underlying model changes. For this you need to register an update counter with every component."
198200
]
199201
},
200202
{
@@ -205,9 +207,11 @@
205207
"source": [
206208
"import solara\n",
207209
"from matplotlib.figure import Figure\n",
210+
"from mesa.visualization.utils import update_counter\n",
208211
"\n",
209212
"@solara.component\n",
210213
"def Histogram(model):\n",
214+
" update_counter.get() # This is required to update the counter\n",
211215
" # Note: you must initialize a figure using this method instead of\n",
212216
" # plt.figure(), for thread safety purpose\n",
213217
" fig = Figure()\n",

0 commit comments

Comments
 (0)