Skip to content

Commit

Permalink
viz tutorial: Update custom plot to reflect new code
Browse files Browse the repository at this point in the history
  • Loading branch information
rht authored and tpike3 committed Sep 13, 2023
1 parent a90b29b commit 9c9a02e
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions docs/tutorials/visualization_tutorial.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -198,18 +198,16 @@
"from matplotlib.figure import Figure\n",
"\n",
"\n",
"def make_histogram(viz):\n",
"def make_histogram(model):\n",
" # Note: you must initialize a figure using this method instead of\n",
" # plt.figure(), for thread safety purpose\n",
" fig = Figure()\n",
" ax = fig.subplots()\n",
" wealth_vals = [agent.wealth for agent in viz.model.schedule.agents]\n",
" wealth_vals = [agent.wealth for agent in model.schedule.agents]\n",
" # Note: you have to use Matplotlib's OOP API instead of plt.hist\n",
" # because plt.hist is not thread-safe.\n",
" ax.hist(wealth_vals, bins=10)\n",
" # You have to specify the dependencies as follows, so that the figure\n",
" # auto-updates when viz.model or viz.df is changed.\n",
" solara.FigureMatplotlib(fig, dependencies=[viz.model, viz.df])"
" solara.FigureMatplotlib(fig)"
]
},
{
Expand Down

0 comments on commit 9c9a02e

Please sign in to comment.