forked from matheus-rech/multilingual-docs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtabby-example.qmd
More file actions
72 lines (56 loc) · 1.87 KB
/
Copy pathtabby-example.qmd
File metadata and controls
72 lines (56 loc) · 1.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
---
title: "Tabby Extension Example"
format: html
editor: source
filters:
- tabby
---
Here is an example of [grouped tabsets](https://quarto.org/docs/output-formats/html-basics.html#tabset-groups) in [Quarto](https://quarto.org/) created with the [Tabby extension](https://quarto.thecoatlessprofessor.com/tabby/). Select Python to see both tabsets switch. The code is [available on GitHub](https://github.com/ivelasq/multilingual-docs/blob/main/tabby-example.qmd).
## First tabset
::: {.tabby group="language"}
```{r}
data("mtcars")
mtcars$fuel_efficiency <- ifelse(mtcars$mpg > 20, "Efficient", "Not Efficient")
plot(
mtcars$wt, mtcars$mpg,
main = "MPG vs. Weight",
xlab = "Weight (1000 lbs)", ylab = "MPG",
col = ifelse(mtcars$fuel_efficiency == "Efficient", "green", "red"), pch = 19
)
legend("topright", legend = c("Efficient", "Not Efficient"), col = c("green", "red"), pch = 19)
```
```{python}
import pandas as pd
from plotnine import ggplot, aes, geom_point, theme_minimal
mtcars = pd.read_csv("https://raw.githubusercontent.com/mwaskom/seaborn-data/master/mpg.csv").dropna()
mtcars['fuel_efficiency'] = ['Efficient' if mpg > 20 else 'Not Efficient' for mpg in mtcars['mpg']]
plot = (
ggplot(mtcars, aes(x='weight', y='mpg', color='fuel_efficiency')) +
geom_point(size=3) +
theme_minimal()
)
plot.show()
```
:::
## Second tabset
::: {.tabby group="language"}
```{r}
library(gt)
towny <- gt::towny
towny_mini <- towny[order(-towny$density_2021), c("name", "website", "density_2021", "land_area_km2", "latitude", "longitude")]
towny_mini <- head(towny_mini, 10)
gt(towny_mini)
```
```{python}
from great_tables import GT, html
from great_tables.data import towny
towny_mini = (
towny[["name", "website", "density_2021", "land_area_km2", "latitude", "longitude"]]
.sort_values("density_2021", ascending=False)
.head(10)
)
(
GT(towny_mini)
)
```
:::