@@ -1554,13 +1554,14 @@ We also reduce the height of each chart
1554
1554
so that they all fit in the same view.
1555
1555
Note that we are re-using the chart we created just above,
1556
1556
instead of re-creating the same chart from scratch.
1557
+ We also explicitly specify that ` facet ` is a categorical variable
1558
+ since faceting should only be done with categorical variables.
1557
1559
1558
1560
``` {code-cell} ipython3
1559
-
1560
1561
morley_hist_facet = morley_hist_categorical.properties(
1561
1562
height=100
1562
1563
).facet(
1563
- "Expt",
1564
+ "Expt:N ",
1564
1565
columns=1
1565
1566
)
1566
1567
```
@@ -1626,7 +1627,7 @@ v_line = alt.Chart(morley_df).mark_rule(strokeDash=[5], size=2).encode(
1626
1627
morley_hist_relative = (morley_hist_rel + v_line).properties(
1627
1628
height=100
1628
1629
).facet(
1629
- "Expt",
1630
+ "Expt:N ",
1630
1631
columns=1,
1631
1632
title="Histogram of relative error of Michelson’s speed of light data"
1632
1633
)
@@ -1719,7 +1720,7 @@ morley_hist_default = alt.Chart(morley_df).mark_bar().encode(
1719
1720
morley_hist_max_bins = alt.vconcat(
1720
1721
alt.hconcat(
1721
1722
(morley_hist_default + v_line).facet(
1722
- 'Expt',
1723
+ 'Expt:N ',
1723
1724
columns=1,
1724
1725
title=alt.TitleParams('Default (bin=True)', fontSize=16, anchor='middle', dx=15)
1725
1726
),
@@ -1730,7 +1731,7 @@ morley_hist_max_bins = alt.vconcat(
1730
1731
title="Relative error (%)"
1731
1732
)
1732
1733
) + v_line).facet(
1733
- 'Expt',
1734
+ 'Expt:N ',
1734
1735
columns=1,
1735
1736
title=alt.TitleParams('maxbins=5', fontSize=16, anchor='middle', dx=15)
1736
1737
),
@@ -1743,7 +1744,7 @@ morley_hist_max_bins = alt.vconcat(
1743
1744
title="Relative error (%)"
1744
1745
)
1745
1746
) + v_line).facet(
1746
- 'Expt',
1747
+ 'Expt:N ',
1747
1748
columns=1,
1748
1749
title=alt.TitleParams('maxbins=70', fontSize=16, anchor='middle', dx=15)
1749
1750
),
@@ -1754,7 +1755,7 @@ morley_hist_max_bins = alt.vconcat(
1754
1755
title="Relative error (%)"
1755
1756
)
1756
1757
) + v_line).facet(
1757
- 'Expt',
1758
+ 'Expt:N ',
1758
1759
columns=1,
1759
1760
title=alt.TitleParams('maxbins=200', fontSize=16, anchor='middle', dx=15)
1760
1761
)
0 commit comments