Skip to content

Commit 556f0b8

Browse files
authored
Fix plots in Shapley tutorial (#161)
* Fix plots in Shapley tutorial * Drop support for older versions of CairoMakie in docs * Fix axis limits * Add missing comma
1 parent f68be78 commit 556f0b8

File tree

2 files changed

+25
-17
lines changed

2 files changed

+25
-17
lines changed

docs/Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ StableRNGs = "860ef19b-820b-49d6-a774-d7a799459cd3"
1515
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
1616

1717
[compat]
18-
CairoMakie = "0.9, 0.10, 0.11"
18+
CairoMakie = "0.11"
1919
Copulas = "0.1"
2020
Distributions = "0.25"
2121
Documenter = "1"

docs/src/tutorials/shapley.md

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -119,14 +119,18 @@ shapley_effects = gsa(
119119
```
120120

121121
```@example shapley
122-
fig = Figure(resolution = (600, 400))
123-
ax = barplot(fig[1, 1], collect(1:54), shapley_effects.shapley_effects, color = :green)
124-
CairoMakie.ylims!(ax.axis, 0.0, 0.2)
125-
ax.axis.xticks = (1:54, ["θ$i" for i in 1:54])
126-
ax.axis.ylabel = "Shapley Indices"
127-
ax.axis.xlabel = "Parameters"
128-
ax.axis.xticklabelrotation = 1
129-
display(fig)
122+
barplot(
123+
1:54, shapley_effects.shapley_effects;
124+
color = :green,
125+
figure = (; size = (600, 400)),
126+
axis = (;
127+
xlabel = "parameters",
128+
xticklabelrotation = 1,
129+
xticks = (1:54, ["θ$i" for i in 1:54]),
130+
ylabel = "Shapley Indices",
131+
limits = (nothing, (0.0, 0.2)),
132+
),
133+
)
130134
```
131135

132136
Now let's assume some correlation between the parameters. We will use a correlation of 0.09 between
@@ -147,12 +151,16 @@ shapley_effects = gsa(
147151
```
148152

149153
```@example shapley
150-
fig = Figure(resolution = (600, 400))
151-
ax = barplot(fig[1, 1], collect(1:54), shapley_effects.shapley_effects, color = :green)
152-
CairoMakie.ylims!(ax.axis, 0.0, 0.2)
153-
ax.axis.xticks = (1:54, ["θ$i" for i in 1:54])
154-
ax.axis.ylabel = "Shapley Indices"
155-
ax.axis.xlabel = "Parameters"
156-
ax.axis.xticklabelrotation = 1
157-
display(fig)
154+
barplot(
155+
1:54, shapley_effects.shapley_effects;
156+
color = :green,
157+
figure = (; size = (600, 400)),
158+
axis = (;
159+
xlabel = "parameters",
160+
xticklabelrotation = 1,
161+
xticks = (1:54, ["θ$i" for i in 1:54]),
162+
ylabel = "Shapley Indices",
163+
limits = (nothing, (0.0, 0.2)),
164+
),
165+
)
158166
```

0 commit comments

Comments
 (0)