Skip to content

Commit 09dfee2

Browse files
committed
Update completed computations files
1 parent f1e5290 commit 09dfee2

File tree

3 files changed

+30
-52
lines changed

3 files changed

+30
-52
lines changed
Lines changed: 10 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
---
22
title: "Quarto Computations"
3-
format:
4-
html:
5-
code-fold: true
6-
code-tools: true
7-
fig-height: 3
8-
fig-width: 10
3+
echo: false
4+
fig-height: 3.5
5+
fig-width: 6
96
---
107

118
This dataset contains a subset of the fuel economy data from the EPA.
@@ -17,42 +14,23 @@ from plotnine import *
1714
from plotnine.data import mpg
1815
```
1916

20-
The plots in @fig-scatterplot show the relationship between city and highway mileage for 38 popular models of cars.
21-
In @fig-scatterplot-1 the points are colored by the number of cylinders while in @fig-scatterplot the points are colored by engine displacement.
17+
@fig-scatterplot shows a positive, strong, and linear relationship between the city and highway mileage of these cars.
18+
Additionally, mileage is higher for cars with fewer cylinders.
2219

2320
```{python}
2421
#| label: fig-scatterplot
22+
#| echo: true
23+
#| code-fold: true
24+
#| code-line-numbers: true
2525
#| fig-cap: "City and highway mileage for 38 popular models of cars."
26-
#| fig-subcap:
27-
#| - "Color by number of cylinders"
28-
#| - "Color by engine displacement, in liters"
29-
#| layout-ncol: 2
30-
#| column: page
26+
#| fig-alt: "Scatterplot of city vs. highway mileage for cars, where points are colored by the number of cylinders. The plot displays a positive, linear, and strong relationship between city and highway mileage, and mileage increases as the number of cylinders decreases."
3127
32-
cyl_plot = (
28+
(
3329
ggplot(mpg, aes(x="hwy", y="cty", color="cyl"))
3430
+ geom_point(alpha=0.5, size=2)
3531
+ scale_color_continuous()
3632
+ theme_bw()
3733
)
38-
39-
cty_plot = (
40-
ggplot(mpg, aes(x="hwy", y="cty", color="displ"))
41-
+ geom_point(alpha=0.5, size=2)
42-
+ scale_color_continuous(cmap_name="cividis")
43-
+ theme_bw()
44-
)
45-
46-
cyl_plot.show()
47-
cty_plot.show()
4834
```
4935

5036
There are `{python} len(mpg)` observations in our data.
51-
52-
```{python}
53-
#| echo: false
54-
mean_cty = round(mpg['cty'].mean(), 2)
55-
mean_hwy = round(mpg['hwy'].mean(), 2)
56-
```
57-
58-
The average city mileage of the cars in our data is `{python} f"{mean_cty:.2f}"` and the average highway mileage is `{python} f"{mean_hwy:.2f}"`.
Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
---
22
title: "Quarto Computations"
3-
format:
4-
html:
5-
code-fold: true
6-
code-tools: true
3+
echo: false
74
fig-height: 3.5
85
fig-width: 6
96
---
@@ -16,27 +13,22 @@ This dataset contains a subset of the fuel economy data from the EPA.
1613
library(ggplot2)
1714
```
1815

19-
The plots in @fig-scatterplot show the relationship between city and highway mileage for 38 popular models of cars.
20-
In @fig-scatterplot-1 the points are colored by the number of cylinders while in @fig-scatterplot the points are colored by engine displacement.
16+
@fig-scatterplot shows a positive, strong, and linear relationship between the city and highway mileage of these cars.
17+
Additionally, mileage is higher for cars with fewer cylinders.
2118

2219
```{r}
2320
#| label: fig-scatterplot
21+
#| echo: true
22+
#| code-fold: true
23+
#| code-line-numbers: true
2424
#| fig-cap: "City and highway mileage for 38 popular models of cars."
25-
#| fig-subcap:
26-
#| - "Color by number of cylinders"
27-
#| - "Color by engine displacement, in liters"
2825
#| fig-alt: "Scatterplot of city vs. highway mileage for cars, where points are colored by the number of cylinders. The plot displays a positive, linear, and strong relationship between city and highway mileage, and mileage increases as the number of cylinders decreases."
29-
#| layout-ncol: 2
30-
#| column: page
3126
3227
ggplot(mpg, aes(x = hwy, y = cty, color = cyl)) +
3328
geom_point(alpha = 0.5, size = 2) +
3429
scale_color_viridis_c() +
3530
theme_minimal()
36-
37-
ggplot(mpg, aes(x = hwy, y = cty, color = displ)) +
38-
geom_point(alpha = 0.5, size = 2) +
39-
scale_color_viridis_c(option = "E") +
40-
theme_minimal()
4131
```
4232

33+
34+
There are `{r} nrow(mpg)` observations in our data.

docs/get-started/computations/positron.qmd

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@ For example, an alternative to showing or hiding code is to use [code folding](/
215215
216216
``` r
217217
#| label: scatterplot
218+
#| echo: true
218219
#| code-fold: true
219220
220221
ggplot(mpg, aes(x = hwy, y = cty, color = cyl)) +
@@ -227,6 +228,7 @@ ggplot(mpg, aes(x = hwy, y = cty, color = cyl)) +
227228
228229
``` python
229230
#| label: scatterplot
231+
#| echo: true
230232
#| code-fold: true
231233
232234
(
@@ -250,7 +252,9 @@ As another example, you can add line numbers to your code cells with the `code-l
250252
251253
``` r
252254
#| label: scatterplot
253-
#| code-line-numbers: true
255+
#| echo: true
256+
#| code-fold: true
257+
#| code-line-numbers: true
254258
255259
ggplot(mpg, aes(x = hwy, y = cty, color = cyl)) +
256260
geom_point(alpha = 0.5, size = 2) +
@@ -262,7 +266,9 @@ ggplot(mpg, aes(x = hwy, y = cty, color = cyl)) +
262266
263267
``` python
264268
#| label: scatterplot
265-
#| code-line-numbers: true
269+
#| echo: true
270+
#| code-fold: true
271+
#| code-line-numbers: true
266272
267273
(
268274
ggplot(mpg, aes(x="hwy", y="cty", color="cyl"))
@@ -303,6 +309,7 @@ format:
303309
304310
To understand which options can be set in the document header, look at the [Reference](/docs/reference) for the format you are using.
305311
For instance, `code-fold` can be set in the document header because it is listed as an [HTML format option](/docs/reference/formats/html.qmd).
312+
You'll learn more about when to set document header options nested under a format versus at the top level in the next tutorial: [Authoring](/docs/get-started/authoring/positron.qmd).
306313

307314
You can see examples of other options that control code appearance in the HTML format in the Guide page [HTML Code Blocks](/docs/output-formats/html-code.qmd).
308315

@@ -349,6 +356,7 @@ You can control the size of all the figures in the document by setting `fig-widt
349356
``` yaml
350357
---
351358
title: "Quarto Computations"
359+
echo: false
352360
fig-height: 3.5
353361
fig-width: 6
354362
---
@@ -386,8 +394,7 @@ To override the figure size for individual images, specify the plot size in your
386394

387395
:::
388396

389-
Quarto provides lots of additional flexibility for figures.
390-
397+
Quarto provides additional flexibility for figures.
391398
You can:
392399

393400
* Produce figure panels with multiple figures, each with its subcaption.
@@ -460,6 +467,7 @@ len(mpg)
460467
:::
461468

462469
Preview the document again to see the output of your code cell.
470+
463471
This isn't a very pretty way to display the number of observations.
464472
An alternative is to use inline code, which we'll cover next.
465473

0 commit comments

Comments
 (0)