Skip to content

Commit

Permalink
finished barchart
Browse files Browse the repository at this point in the history
  • Loading branch information
dicook committed Oct 22, 2024
1 parent f7eeb5f commit a92799d
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.Rmd
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
title: "Some Guidance for Writing `alt text` for Data Plots"
title: "Some Guidance for Writing alt text for Data Plots"
author: "Krisanat Anukarnsakulchularp and Di Cook"
output: github_document
always_allow_html: true
Expand Down
11 changes: 9 additions & 2 deletions example.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,19 @@ ggplot(electoral$polls,
#| fig-height: 4
#| out-width: 40%
#| fig-alt: Bar chart of numbers of different classes of vehicles.
library(dplyr)
mpg <- mpg |>
mutate(class = factor(class, levels = c("suv", "pickup", "midsize",
"compact", "subcompact", "minivan", "2seater")))
ggplot(mpg, aes(x=class, weight = displ)) +
geom_bar() +
coord_flip()
coord_flip() +
xlab("")
```

**Alt text**: Bar chart of numbers of different classes of vehicles.
**Alt text**: Bar chart of numbers of different classes of vehicles. Counts range from 25 to 275. There are 7 classes of vehicle: suv, pickup, midsize, compact, subcompact, minivan, 2seater, corresponding to the order og highest to lowest count.

**Caption**: Examining the relative popularity of different types of cars. The most popular is SUV, which is almost twice as many as pickups.

### Animated visualisation

Expand Down
21 changes: 20 additions & 1 deletion example.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,33 @@ There is one democratic state with a massive margin of 80%.
### Barchart

``` r
library(dplyr)
#>
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#>
#> filter, lag
#> The following objects are masked from 'package:base':
#>
#> intersect, setdiff, setequal, union
mpg <- mpg |>
mutate(class = factor(class, levels = c("suv", "pickup", "midsize",
"compact", "subcompact", "minivan", "2seater")))
ggplot(mpg, aes(x=class, weight = displ)) +
geom_bar() +
coord_flip()
coord_flip() +
xlab("")
```

<img src="figures/barchart-1.png" alt="Bar chart of numbers of different classes of vehicles." width="40%" />

**Alt text**: Bar chart of numbers of different classes of vehicles.
Counts range from 25 to 275. There are 7 classes of vehicle: suv,
pickup, midsize, compact, subcompact, minivan, 2seater, corresponding to
the order og highest to lowest count.

**Caption**: Examining the relative popularity of different types of
cars. The most popular is SUV, which is almost twice as many as pickups.

### Animated visualisation

Expand Down
Binary file modified figures/barchart-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit a92799d

Please sign in to comment.