Skip to content

Commit

Permalink
Merge pull request #228 from UBC-DSCI/main
Browse files Browse the repository at this point in the history
Fix build warnings
  • Loading branch information
trevorcampbell authored Aug 31, 2023
2 parents cbfd430 + 44a1ab5 commit 26eb920
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 19 deletions.
24 changes: 12 additions & 12 deletions source/inference.md
Original file line number Diff line number Diff line change
Expand Up @@ -1122,27 +1122,26 @@ the true sampling distribution—which corresponds to taking many samples fr
```{code-cell} ipython3
:tags: [remove-input]
sampling_distribution.encoding.x['bin']['extent'] = (90, 250)
alt.vconcat(
alt.layer(
sampling_distribution,
sampling_distribution.mark_rule(color='#f58518', size=2).encode(x='mean(mean_price)', y=alt.Y()),
sampling_distribution.mark_text(color='#f58518', size=12, align='left', dx=16, fontWeight='bold').encode(
alt.Chart(sample_estimates).mark_rule(color='#f58518', size=2).encode(x='mean(mean_price)'),
alt.Chart(sample_estimates).mark_text(color='#f58518', size=12, align='left', dx=16, fontWeight='bold').encode(
x='mean(mean_price)',
y=alt.value(7),
text=alt.value(f"Mean = {sampling_distribution['data']['mean_price'].mean().round(1)}")
)
).properties(title='Sampling distribution', height=150),
alt.layer(
boot_est_dist,
boot_est_dist.mark_rule(color='#f58518', size=2).encode(x='mean(mean_price)', y=alt.Y()),
boot_est_dist.mark_text(color='#f58518', size=12, align='left', dx=18, fontWeight='bold').encode(
alt.Chart(boot20000_means).mark_rule(color='#f58518', size=2).encode(x='mean(mean_price)'),
alt.Chart(boot20000_means).mark_text(color='#f58518', size=12, align='left', dx=18, fontWeight='bold').encode(
x='mean(mean_price)',
y=alt.value(6),
y=alt.value(7),
text=alt.value(f"Mean = {boot_est_dist['data']['mean_price'].mean().round(1)}")
)
).properties(title='Bootstrap distribution', height=150)
).resolve_scale(
x='shared'
)
```

Expand Down Expand Up @@ -1252,18 +1251,19 @@ visualize the interval on our distribution in {numref}`fig:11-bootstrapping9`.

```{code-cell} ipython3
# Create the annotation for for the 2.5th percentile
text_025 = alt.Chart().mark_text(
rule_025 = alt.Chart().mark_rule(color='#f58518', size=3, strokeDash=[5]).encode(
x=alt.datum(ci_bounds[0.025])
).properties(
width=500
)
text_025 = rule_025.mark_text(
color='#f58518',
size=12,
fontWeight='bold',
dy=-160
).encode(
x=alt.datum(ci_bounds[0.025]),
text=alt.datum(f'2.5th percentile ({ci_bounds[0.025].round(1)})')
).properties(
width=500
)
rule_025 = text_025.mark_rule(color='#f58518', size=3, strokeDash=[5])
# Create the annotation for for the 97.5th percentile
text_975 = text_025.encode(
Expand Down
15 changes: 8 additions & 7 deletions source/viz.md
Original file line number Diff line number Diff line change
Expand Up @@ -1554,13 +1554,14 @@ We also reduce the height of each chart
so that they all fit in the same view.
Note that we are re-using the chart we created just above,
instead of re-creating the same chart from scratch.
We also explicitly specify that `facet` is a categorical variable
since faceting should only be done with categorical variables.

```{code-cell} ipython3
morley_hist_facet = morley_hist_categorical.properties(
height=100
).facet(
"Expt",
"Expt:N",
columns=1
)
```
Expand Down Expand Up @@ -1626,7 +1627,7 @@ v_line = alt.Chart(morley_df).mark_rule(strokeDash=[5], size=2).encode(
morley_hist_relative = (morley_hist_rel + v_line).properties(
height=100
).facet(
"Expt",
"Expt:N",
columns=1,
title="Histogram of relative error of Michelson’s speed of light data"
)
Expand Down Expand Up @@ -1719,7 +1720,7 @@ morley_hist_default = alt.Chart(morley_df).mark_bar().encode(
morley_hist_max_bins = alt.vconcat(
alt.hconcat(
(morley_hist_default + v_line).facet(
'Expt',
'Expt:N',
columns=1,
title=alt.TitleParams('Default (bin=True)', fontSize=16, anchor='middle', dx=15)
),
Expand All @@ -1730,7 +1731,7 @@ morley_hist_max_bins = alt.vconcat(
title="Relative error (%)"
)
) + v_line).facet(
'Expt',
'Expt:N',
columns=1,
title=alt.TitleParams('maxbins=5', fontSize=16, anchor='middle', dx=15)
),
Expand All @@ -1743,7 +1744,7 @@ morley_hist_max_bins = alt.vconcat(
title="Relative error (%)"
)
) + v_line).facet(
'Expt',
'Expt:N',
columns=1,
title=alt.TitleParams('maxbins=70', fontSize=16, anchor='middle', dx=15)
),
Expand All @@ -1754,7 +1755,7 @@ morley_hist_max_bins = alt.vconcat(
title="Relative error (%)"
)
) + v_line).facet(
'Expt',
'Expt:N',
columns=1,
title=alt.TitleParams('maxbins=200', fontSize=16, anchor='middle', dx=15)
)
Expand Down

0 comments on commit 26eb920

Please sign in to comment.