Skip to content

Commit

Permalink
Use "risk attitude" instead of "risk level" in charts
Browse files Browse the repository at this point in the history
  • Loading branch information
rlskoeser committed Aug 2, 2024
1 parent a1f5907 commit 11f244c
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
6 changes: 5 additions & 1 deletion simulatingrisk/hawkdove/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@ def plot_wealth(model):
risk_wealth = [(agent.risk_level, agent.points) for agent in model.schedule.agents]
df = pd.DataFrame(risk_wealth, columns=["risk_level", "wealth"])

chart = alt.Chart(df).mark_bar().encode(y="wealth", x="risk_level")
chart = (
alt.Chart(df)
.mark_bar()
.encode(y="wealth", x=alt.X("risk_level", title="risk attitude"))
)
return solara.FigureAltair(chart)


Expand Down
2 changes: 1 addition & 1 deletion simulatingrisk/hawkdove/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ def draw_hawkdove_agent_space(model, agent_portrayal):
# optionally display information from multi-risk attitude variant
if "risk_level_changed" in df.columns:
outer_color = alt.Color(
"risk_level_changed", title="adjusted risk level"
"risk_level_changed", title="adjusted risk attitude"
).scale(
domain=[False, True],
range=["transparent", "black"],
Expand Down
15 changes: 9 additions & 6 deletions simulatingrisk/hawkdovemulti/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def plot_agents_by_risk(model):
# distracting from the main point of this chart, which is quantitative
# color=alt.Color("risk_level:N").scale(**color_scale_opts),
)
.properties(title="Number of agents in each risk level")
.properties(title="Number of agents with each risk attitude")
)
return solara.FigureAltair(bar_chart)

Expand All @@ -113,7 +113,7 @@ def plot_risklevel_changes(model):
model_df.rename(
columns={
"num_agents_risk_changed": "agents",
"sum_risk_level_changes": "risk level totals",
"sum_risk_level_changes": "risk attitude totals",
},
inplace=True,
)
Expand All @@ -136,7 +136,7 @@ def plot_risklevel_changes(model):
x=alt.X("index"),
color="category",
)
.properties(title="Risk level adjustments")
.properties(title="Risk attitude adjustments")
)

return solara.FigureAltair(line_chart)
Expand Down Expand Up @@ -189,7 +189,9 @@ def plot_hawks_by_risk(model):
title="rolling % hawk",
scale=alt.Scale(domain=[0, 1]),
),
color=alt.Color("risk_level:N").scale(**color_scale_opts),
color=alt.Color("risk_level:N", title="risk attitude").scale(
**color_scale_opts
),
)
.properties(title="Rolling average percent hawk by risk level")
)
Expand All @@ -213,10 +215,11 @@ def plot_wealth_by_risklevel(model):
alt.X(
"risk_level",
scale=alt.Scale(domain=[model.min_risk_level, model.max_risk_level]),
title="risk attitude",
),
alt.Y("points").scale(zero=False),
alt.Y("points", title="wealth").scale(zero=False),
)
.properties(title="Cumulative wealth by risk level")
.properties(title="Cumulative wealth by risk attitude")
)
return solara.FigureAltair(wealth_chart)

Expand Down

0 comments on commit 11f244c

Please sign in to comment.