From e0cd7e53df3fc83549182052ce35d3a61dd794da Mon Sep 17 00:00:00 2001
From: Rosetta <135234996+gisellerosetta@users.noreply.github.com>
Date: Tue, 26 Nov 2024 15:58:28 +0000
Subject: [PATCH 01/17] updated bar chart examples
---
README.md | 61 ++-
man/figures/README-ex1-1.svg | 598 +++----------------------
man/figures/README-ex2-1.svg | 490 +++-----------------
man/figures/README-ex3-1.svg | 67 +++
vignettes/cookbook/_annotations.Rmd | 2 +-
vignettes/cookbook/_chart-types.Rmd | 45 +-
vignettes/cookbook/_customisations.Rmd | 6 +-
7 files changed, 272 insertions(+), 997 deletions(-)
create mode 100644 man/figures/README-ex3-1.svg
diff --git a/README.md b/README.md
index 94130f6..53ea035 100644
--- a/README.md
+++ b/README.md
@@ -1,3 +1,8 @@
+---
+editor_options:
+ markdown:
+ wrap: 72
+---
@@ -10,6 +15,7 @@ date)](https://img.shields.io/github/v/release/best-practice-and-impact/afcharts
[![R build
status](https://github.com/best-practice-and-impact/afcharts/workflows/R-CMD-check/badge.svg)](https://github.com/best-practice-and-impact/afcharts/actions)
[![R-CMD-check](https://github.com/best-practice-and-impact/afcharts/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/best-practice-and-impact/afcharts/actions/workflows/R-CMD-check.yaml)
+
afcharts is an R package for creating accessible plots by the Government
@@ -84,44 +90,67 @@ library(gapminder)
library(afcharts)
gapminder |>
- filter(year == 2007 & continent == "Europe") |>
- slice_max(order_by = lifeExp, n = 5) |>
- ggplot() +
- geom_col(aes(x = reorder(country, -lifeExp), y = lifeExp)) +
+ filter(year == 2007 & continent == "Americas") |>
+ slice_max(order_by = pop, n = 5) |>
+ ggplot(aes(x = reorder(country, -pop), y = pop/(10^6))) +
+ geom_col() +
scale_y_continuous(expand = c(0, 0)) +
labs(
x = NULL,
y = NULL,
- title = "Iceland has the highest life expectancy in Europe",
- subtitle = "Life expectancy in European countries, 2007",
+ title = "The U.S.A. is the most populous country in the Americas",
+ subtitle = "Population of countries in the Americas (millions), 2007",
caption = "Source: Gapminder"
- )
+ )
```
-
+
#### Example 2: Plot with one colour using afcharts defaults
``` r
afcharts::use_afcharts()
#> NULL
-
gapminder |>
- filter(year == 2007 & continent == "Europe") |>
- slice_max(order_by = lifeExp, n = 5) |>
- ggplot() +
- geom_col(aes(x = reorder(country, -lifeExp), y = lifeExp)) +
+ filter(year == 2007 & continent == "Americas") |>
+ slice_max(order_by = pop, n = 5) |>
+ ggplot(aes(x = reorder(country, -pop), y = pop/(10^6))) +
+ geom_col(fill = af_colour_values["dark-blue"]) +
+ scale_y_continuous(expand = c(0, 0)) +
+ labs(
+ x = NULL,
+ y = NULL,
+ title = "The U.S.A. is the most populous country in\nthe Americas",
+ subtitle = "Population of countries in the Americas (millions), 2007",
+ caption = "Source: Gapminder"
+ )
+```
+
+
+
+#### Example 3: Plot with focus colours using afcharts
+
+``` r
+pop_bar_data |>
+ ggplot(
+ aes(x = reorder(country, -pop), y = pop/(10^6),
+ fill = country == "Brazil")
+ ) +
+ geom_col() +
+ theme_af(legend = "none") +
scale_y_continuous(expand = c(0, 0)) +
+ scale_fill_discrete_af("focus", reverse = TRUE) +
labs(
x = NULL,
y = NULL,
- title = "Iceland has the highest life expectancy in Europe",
- subtitle = "Life expectancy in European countries, 2007",
+ title = "Brazil has the second highest population in\nthe Americas",
+ subtitle = "Population of countries in the Americas (millions), 2007",
caption = "Source: Gapminder"
)
+ )
```
-
+
**Note on use of titles, subtitles and captions**
Titles, subtitles
and captions have been embedded in these example charts for
diff --git a/man/figures/README-ex1-1.svg b/man/figures/README-ex1-1.svg
index c0cc16a..1a7a840 100644
--- a/man/figures/README-ex1-1.svg
+++ b/man/figures/README-ex1-1.svg
@@ -1,534 +1,74 @@
-
-