Skip to content

Commit 4fda1a3

Browse files
committed
Build out based on other IDE flows
1 parent 4370e5a commit 4fda1a3

23 files changed

+750
-0
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*.html
2+
*_files/
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
---
2+
title: "Quarto Computations"
3+
format:
4+
html:
5+
code-fold: true
6+
code-tools: true
7+
fig-height: 3
8+
fig-width: 10
9+
---
10+
11+
This dataset contains a subset of the fuel economy data from the EPA.
12+
13+
```{python}
14+
#| label: load-packages
15+
16+
from plotnine import *
17+
from plotnine.data import mpg
18+
```
19+
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.
22+
23+
```{python}
24+
#| label: fig-scatterplot
25+
#| 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
31+
32+
cyl_plot = (
33+
ggplot(mpg, aes(x="hwy", y="cty", color="cyl"))
34+
+ geom_point(alpha=0.5, size=2)
35+
+ scale_color_continuous()
36+
+ theme_bw()
37+
)
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()
48+
```
49+
50+
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: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
---
2+
title: "Quarto Computations"
3+
---
4+
5+
This dataset contains a subset of the fuel economy data from the EPA.
6+
7+
```{python}
8+
#| label: load-packages
9+
10+
from plotnine import *
11+
from plotnine.data import mpg
12+
```
13+
14+
The visualization below shows a positive, strong, and linear relationship between the city and highway mileage of these cars.
15+
Additionally, mileage is higher for cars with fewer cylinders.
16+
17+
```{python}
18+
#| label: scatterplot
19+
20+
(
21+
ggplot(mpg, aes(x="hwy", y="cty", color="cyl"))
22+
+ geom_point(alpha=0.5, size=2)
23+
+ scale_color_continuous()
24+
+ theme_bw()
25+
)
26+
```
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
---
2+
title: "Quarto Computations"
3+
format:
4+
html:
5+
code-fold: true
6+
code-tools: true
7+
fig-height: 3.5
8+
fig-width: 6
9+
---
10+
11+
This dataset contains a subset of the fuel economy data from the EPA.
12+
13+
```{r}
14+
#| label: load-packages
15+
16+
library(ggplot2)
17+
```
18+
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.
21+
22+
```{r}
23+
#| label: fig-scatterplot
24+
#| 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"
28+
#| 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
31+
32+
ggplot(mpg, aes(x = hwy, y = cty, color = cyl)) +
33+
geom_point(alpha = 0.5, size = 2) +
34+
scale_color_viridis_c() +
35+
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()
41+
```
42+
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
---
2+
title: "Quarto Computations"
3+
---
4+
5+
This dataset contains a subset of the fuel economy data from the EPA.
6+
Specifically, we use the `mpg` dataset from the **ggplot2** package.
7+
8+
```{r}
9+
#| label: load-packages
10+
11+
library(ggplot2)
12+
```
13+
14+
The visualization below shows a positive, strong, and linear relationship between the city and highway mileage of these cars.
15+
Additionally, mileage is higher for cars with fewer cylinders.
16+
17+
```{r}
18+
#| label: scatterplot
19+
20+
ggplot(mpg, aes(x = hwy, y = cty, color = cyl)) +
21+
geom_point(alpha = 0.5, size = 2) +
22+
scale_color_viridis_c() +
23+
theme_bw()
24+
```
227 KB
Loading
223 KB
Loading
205 KB
Loading
193 KB
Loading
229 KB
Loading

0 commit comments

Comments
 (0)