diff --git a/DESCRIPTION b/DESCRIPTION
index 2cd09f4..65d67ce 100644
--- a/DESCRIPTION
+++ b/DESCRIPTION
@@ -18,7 +18,8 @@ Depends:
Imports:
ggplot2,
stringr,
- systemfonts
+ systemfonts,
+ withr
Encoding: UTF-8
LazyData: true
RoxygenNote: 7.3.1
diff --git a/NAMESPACE b/NAMESPACE
index ebb6c06..787850a 100644
--- a/NAMESPACE
+++ b/NAMESPACE
@@ -1,5 +1,6 @@
# Generated by roxygen2: do not edit by hand
+S3method(print,palette)
export(acdc_black)
export(acdc_brown)
export(acdc_dark_green)
@@ -14,6 +15,22 @@ export(get_colour)
export(get_colours)
export(motif_fonts)
export(set_acdc_font)
+export(theme_acdc_dark)
export(theme_acdc_light)
+importFrom(ggplot2,element_blank)
+importFrom(ggplot2,element_line)
+importFrom(ggplot2,element_rect)
+importFrom(ggplot2,element_text)
+importFrom(ggplot2,margin)
+importFrom(ggplot2,theme)
+importFrom(ggplot2,theme_minimal)
+importFrom(grDevices,col2rgb)
+importFrom(grDevices,colorRampPalette)
+importFrom(grDevices,rgb)
+importFrom(graphics,image)
+importFrom(graphics,par)
+importFrom(graphics,rect)
+importFrom(graphics,text)
+importFrom(grid,unit)
importFrom(stringr,str_detect)
importFrom(systemfonts,system_fonts)
diff --git a/R/africa_cdc.R b/R/africa_cdc.R
index dba1a2d..6f177f9 100644
--- a/R/africa_cdc.R
+++ b/R/africa_cdc.R
@@ -122,22 +122,58 @@ set_acdc_font <- function(alt = motif_fonts$motif_noto) {
#'
#' A [ggplot2] theme using Africa CDC fonts, colours, and palettes
#'
-#' @param base_family Base font family. Default is set by what is available in
-#' the sytem via `set_acdc_font()`.
-#' @param base_size Base font size. Default is 11.5
-#' @param plot_title_family,plot_title_face,plot_title_size,plot_title_margin,plot_title_colour plot title family, face, size and margi
-#' @param subtitle_family,subtitle_face,subtitle_size,subtitle_colour plot subtitle family, face and size
-#' @param subtitle_margin plot subtitle margin bottom (single numeric value)
-#' @param strip_text_family,strip_text_face,strip_text_size facet label font family, face and size
-#' @param caption_family,caption_face,caption_size,caption_margin,caption_colour plot caption family, face, size and margin
-#' @param axis_title_family,axis_title_face,axis_title_size,axis_title_colour axis title font family, face and size
-#' @param axis_title_just axis title font justification, one of `[blmcrt]`
-#' @param plot_margin plot margin (specify with `ggplot2::margin()`)
-#' @param grid_col,axis_col grid & axis colors; both default to `#cccccc`
-#' @param grid panel grid (`TRUE`, `FALSE`, or a combination of `X`, `x`, `Y`, `y`)
-#' @param axis_text_size font size of axis text
-#' @param axis add x or y axes? `TRUE`, `FALSE`, "`xy`"
-#' @param ticks ticks if `TRUE` add ticks
+#' @param base_family Base font family using Africa CDC fonts. Default is set
+#' by what Africa CDC font is available in the sytem via `set_acdc_font()`. If
+#' none of the Africa CDC fonts are available, the default becomes Noto Sans.
+#' @param base_size Base font size. Default is 11.5.
+#' @param plot_title_family Font family to use for the plot title. Default is
+#' `base_family`.
+#' @param plot_title_face Font face ("plain", "italic", "bold", "bold.italic")
+#' for plot title. Default is "bold".
+#' @param plot_title_size Plot title text size in pts. Default is 18.
+#' @param plot_title_margin Margin at the bottom of the plot title. Default
+#' set at 10.
+#' @param plot_title_colour Colour of the plot title text. Default
+#' is `acdc_green`.
+#' @param subtitle_family Font family to use for the plot subtitle. Default is
+#' `base_family`.
+#' @param subtitle_face Font face ("plain", "italic", "bold", "bold.italic")
+#' for plot subtitle. Default is "plain".
+#' @param subtitle_size Plot subtitle text size in pts. Default is 12.
+#' @param subtitle_colour Colour of the subtitle text. Default is `acdc_gold`.
+#' @param subtitle_margin Margin at the bottom of the plot subtitle. Default
+#' set at 15.
+#' @param strip_text_family Font family to use for the facet label. Default is
+#' `base_family`.
+#' @param strip_text_face Font face ("plain", "italic", "bold", "bold.italic")
+#' for facet label. Default is "plain".
+#' @param strip_text_size Facet label text size in pts. Default is 12.
+#' @param caption_family Font family to use for the caption text. Default is
+#' `base_family`.
+#' @param caption_face Font face ("plain", "italic", "bold", "bold.italic") for
+#' caption text. Default is "plain".
+#' @param caption_size Caption text size in pts. Default is 9.
+#' @param caption_margin Margin at the top of the plot caption text. Default is
+#' set at 10.
+#' @param caption_colour Colour of the caption text. Default is `acdc_gold`.
+#' @param axis_title_family Font family to use for the axis title. Default is
+#' `base_family`.
+#' @param axis_title_face Font face ("plain", "italic", "bold", "bold.italic")
+#' for axis title. Default is "plain".
+#' @param axis_title_size Axis title text size in pts. Default is 9.
+#' @param axis_title_colour Colour of the axis title text. Default is
+#' `acdc_gold`.
+#' @param axis_title_just Axis title font justification, one of
+#' "bl" (bottom-left), "m" (middle), "rt" (right-top). Default is "rt".
+#' @param plot_margin Plot margins (specify with `ggplot2::margin()`)
+#' @param grid_col Grid colour. Default to `acdc_gold`.
+#' @param axis_col Axis colors. Default to `acdc_gold`.
+#' @param grid Panel grid. Either `TRUE`, `FALSE`, or a combination of
+#' `X` (major x grid), `x` (minor x grid), `Y` (major y grid), and/or
+#' `y` (minor y grid). Default is TRUE.
+#' @param axis_text_size Axis text size in pts. Default is `base_size`.
+#' @param axis Add x or y axes? `TRUE`, `FALSE`, "`xy`". Default is FALSE.
+#' @param ticks Logical. Should ticks be added? Default is FALSE.
#'
#' @return A [ggplot2] theme.
#'
@@ -184,7 +220,7 @@ theme_acdc_light <- function(base_family = set_acdc_font(),
caption_family = base_family,
caption_size = 9,
caption_face = "italic",
- caption_colour = acdc_green,
+ caption_colour = acdc_gold,
caption_margin = 10,
axis_text_size = base_size,
axis_title_family = subtitle_family,
@@ -255,6 +291,7 @@ theme_acdc_light <- function(base_family = set_acdc_font(),
ggplot2::theme(panel.grid = ggplot2::element_blank())
}
+ ## Set axis design ----
if (inherits(axis, "character") | axis == TRUE) {
design <- design +
ggplot2::theme(
@@ -298,6 +335,7 @@ theme_acdc_light <- function(base_family = set_acdc_font(),
design <- design + ggplot2::theme(axis.line = ggplot2::element_blank())
}
+ ## Set ticks design ----
if (!ticks) {
design <- design + ggplot2::theme(axis.ticks = ggplot2::element_blank())
design <- design + ggplot2::theme(axis.ticks.x = ggplot2::element_blank())
@@ -313,6 +351,7 @@ theme_acdc_light <- function(base_family = set_acdc_font(),
ggplot2::theme(axis.ticks.length = grid::unit(5, "pt"))
}
+ ## Set axis text design ----
xj <- switch(
tolower(substr(axis_title_just, 1, 1)),
b = 0, l = 0, m = 0.5, c = 0.5, r = 1, t = 1
@@ -322,18 +361,23 @@ theme_acdc_light <- function(base_family = set_acdc_font(),
b = 0, l = 0, m = 0.5, c = 0.5, r = 1, t = 1
)
+ ### x-axis text ----
design <- design +
ggplot2::theme(
axis.text.x = ggplot2::element_text(
size = axis_text_size, margin = ggplot2::margin(t = 0)
)
)
+
+ ### y-axis text ----
design <- design +
ggplot2::theme(
axis.text.y = ggplot2::element_text(
size = axis_text_size, margin = ggplot2::margin(r = 0)
)
)
+
+ ### axis titles ----
design <- design +
ggplot2::theme(
axis.title = ggplot2::element_text(
@@ -341,6 +385,8 @@ theme_acdc_light <- function(base_family = set_acdc_font(),
colour = axis_title_colour
)
)
+
+ ### axis title adjustment ----
design <- design +
ggplot2::theme(
axis.title.x = ggplot2::element_text(
@@ -348,6 +394,274 @@ theme_acdc_light <- function(base_family = set_acdc_font(),
family = axis_title_family, face = axis_title_face
)
)
+
+ design <- design +
+ ggplot2::theme(
+ axis.title.y = ggplot2::element_text(
+ hjust = yj, size = axis_title_size,
+ family = axis_title_family, face = axis_title_face
+ )
+ )
+
+ ### y-axis on the right ----
+ design <- design +
+ ggplot2::theme(
+ axis.title.y.right = ggplot2::element_text(
+ hjust = yj, size = axis_title_size, angle = 90,
+ family = axis_title_family, face = axis_title_face
+ )
+ )
+
+ ### Set facet label design ----
+ design <- design +
+ ggplot2::theme(
+ strip.text = ggplot2::element_text(
+ hjust = 0, size = strip_text_size,
+ face = strip_text_face, family = strip_text_family
+ )
+ )
+
+ ### Set facet design ----
+ design <- design +
+ ggplot2::theme(panel.spacing = grid::unit(2, "lines"))
+
+ ### Set plot title design ----
+ design <- design +
+ ggplot2::theme(
+ plot.title = ggplot2::element_text(
+ hjust = 0, size = plot_title_size, colour = plot_title_colour,
+ margin = ggplot2::margin(b = plot_title_margin),
+ family = plot_title_family, face = plot_title_face)
+ )
+
+ ### Set plot subtitle design ----
+ design <- design +
+ ggplot2::theme(
+ plot.subtitle = ggplot2::element_text(
+ hjust = 0, size = subtitle_size, colour = subtitle_colour,
+ margin = ggplot2::margin(b = subtitle_margin),
+ family = subtitle_family, face = subtitle_face
+ )
+ )
+
+ ### Set plot caption design ----
+ design <- design +
+ ggplot2::theme(
+ plot.caption = ggplot2::element_text(
+ hjust = 1, size = caption_size, colour = caption_colour,
+ margin = ggplot2::margin(t = caption_margin),
+ family = caption_family, face = caption_face
+ )
+ )
+
+ ### Set plot margins ----
+ design <- design + ggplot2::theme(plot.margin = plot_margin)
+
+ ## return design ----
+ design
+}
+
+
+#'
+#' @rdname theme_acdc
+#' @export
+#'
+theme_acdc_dark <- function(base_family = set_acdc_font(),
+ base_size = 11.5,
+ plot_title_family = base_family,
+ plot_title_size = 18,
+ plot_title_face = "bold",
+ plot_title_colour = acdc_green,
+ plot_title_margin = 10,
+ subtitle_family = base_family,
+ subtitle_size = 12,
+ subtitle_face = "plain",
+ subtitle_colour = acdc_black,
+ subtitle_margin = 15,
+ strip_text_family = base_family,
+ strip_text_size = 12,
+ strip_text_face = "plain",
+ caption_family = base_family,
+ caption_size = 9,
+ caption_face = "italic",
+ caption_colour = acdc_black,
+ caption_margin = 10,
+ axis_text_size = base_size,
+ axis_title_family = subtitle_family,
+ axis_title_size = 9,
+ axis_title_colour = acdc_black,
+ axis_title_face = "plain",
+ axis_title_just = "rt",
+ plot_margin = ggplot2::margin(30, 30, 30, 30),
+ grid_col = acdc_green,
+ grid = TRUE,
+ axis_col = acdc_green,
+ axis = FALSE,
+ ticks = FALSE) {
+ ## Set theme_minial ----
+ design <- ggplot2::theme_minimal(
+ base_family = base_family, base_size = base_size
+ )
+
+ ## Set plot background design ----
+ design <- design +
+ ggplot2::theme(plot.background = ggplot2::element_rect(fill = acdc_gold))
+
+ ## Set legend design ----
+ design <- design +
+ ggplot2::theme(
+ legend.background = ggplot2::element_blank(),
+ legend.key = ggplot2::element_blank(),
+ legend.title = ggplot2::element_text(
+ family = base_family, colour = acdc_black
+ ),
+ legend.text = ggplot2::element_text(
+ family = base_family, colour = acdc_black
+ )
+ )
+
+ ## Set grid design ----
+ if (inherits(grid, "character") | grid == TRUE) {
+ design <- design +
+ ggplot2::theme(
+ panel.grid = ggplot2::element_line(color = grid_col, size = 0.2)
+ )
+
+ design <- design +
+ ggplot2::theme(
+ panel.grid.major = ggplot2::element_line(color = grid_col, size = 0.2)
+ )
+
+ design <- design +
+ ggplot2::theme(
+ panel.grid.minor = ggplot2::element_line(color = grid_col, size = 0.05)
+ )
+
+ if (inherits(grid, "character")) {
+ if (regexpr("X", grid)[1] < 0)
+ design <- design +
+ ggplot2::theme(panel.grid.major.x = ggplot2::element_blank())
+
+ if (regexpr("Y", grid)[1] < 0)
+ design <- design +
+ ggplot2::theme(panel.grid.major.y = ggplot2::element_blank())
+
+ if (regexpr("x", grid)[1] < 0)
+ design <- design +
+ ggplot2::theme(panel.grid.minor.x = ggplot2::element_blank())
+
+ if (regexpr("y", grid)[1] < 0)
+ design <- design +
+ ggplot2::theme(panel.grid.minor.y = ggplot2::element_blank())
+ }
+ } else {
+ design <- design +
+ ggplot2::theme(panel.grid = ggplot2::element_blank())
+ }
+
+ ## Set axis design ----
+ if (inherits(axis, "character") | axis == TRUE) {
+ design <- design +
+ ggplot2::theme(
+ axis.line = ggplot2::element_line(color = acdc_green, size = 0.15)
+ )
+
+ if (inherits(axis, "character")) {
+ axis <- tolower(axis)
+
+ if (regexpr("x", axis)[1] < 0) {
+ design <- design +
+ ggplot2::theme(axis.line.x = ggplot2::element_blank())
+ } else {
+ design <- design +
+ ggplot2::theme(
+ axis.line.x = ggplot2::element_line(color = axis_col, size = 0.15)
+ )
+ }
+
+ if (regexpr("y", axis)[1] < 0) {
+ design <- design +
+ ggplot2::theme(axis.line.y = ggplot2::element_blank())
+ } else {
+ design <- design +
+ ggplot2::theme(
+ axis.line.y = ggplot2::element_line(color = axis_col, size = 0.15)
+ )
+ }
+ } else {
+ design <- design +
+ ggplot2::theme(
+ axis.line.x = ggplot2::element_line(color = axis_col, size = 0.15)
+ )
+
+ design <- design +
+ ggplot2::theme(
+ axis.line.y = ggplot2::element_line(color = axis_col, size = 0.15)
+ )
+ }
+ } else {
+ design <- design + ggplot2::theme(axis.line = ggplot2::element_blank())
+ }
+
+ ## Set ticks design ----
+ if (!ticks) {
+ design <- design + ggplot2::theme(axis.ticks = ggplot2::element_blank())
+ design <- design + ggplot2::theme(axis.ticks.x = ggplot2::element_blank())
+ design <- design + ggplot2::theme(axis.ticks.y = ggplot2::element_blank())
+ } else {
+ design <- design +
+ ggplot2::theme(axis.ticks = ggplot2::element_line(linewidth = 0.15))
+ design <- design +
+ ggplot2::theme(axis.ticks.x = ggplot2::element_line(linewidth = 0.15))
+ design <- design +
+ ggplot2::theme(axis.ticks.y = ggplot2::element_line(linewidth = 0.15))
+ design <- design +
+ ggplot2::theme(axis.ticks.length = grid::unit(5, "pt"))
+ }
+
+ ## Set axis text design ----
+ xj <- switch(
+ tolower(substr(axis_title_just, 1, 1)),
+ b = 0, l = 0, m = 0.5, c = 0.5, r = 1, t = 1
+ )
+ yj <- switch(
+ tolower(substr(axis_title_just, 2, 2)),
+ b = 0, l = 0, m = 0.5, c = 0.5, r = 1, t = 1
+ )
+
+ design <- design +
+ ggplot2::theme(
+ axis.text.x = ggplot2::element_text(
+ size = axis_text_size, margin = ggplot2::margin(t = 0)
+ )
+ )
+
+ design <- design +
+ ggplot2::theme(
+ axis.text.y = ggplot2::element_text(
+ size = axis_text_size, margin = ggplot2::margin(r = 0)
+ )
+ )
+
+ ## Set axis title text design ----
+ design <- design +
+ ggplot2::theme(
+ axis.title = ggplot2::element_text(
+ size = axis_title_size, family = axis_title_family,
+ colour = axis_title_colour
+ )
+ )
+
+ ### Set x-axis placement ----
+ design <- design +
+ ggplot2::theme(
+ axis.title.x = ggplot2::element_text(
+ hjust = xj, size = axis_title_size,
+ family = axis_title_family, face = axis_title_face
+ )
+ )
+
+ ### Set y-axis placement ----
design <- design +
ggplot2::theme(
axis.title.y = ggplot2::element_text(
@@ -355,6 +669,8 @@ theme_acdc_light <- function(base_family = set_acdc_font(),
family = axis_title_family, face = axis_title_face
)
)
+
+ ### Set y-axis right side placement ----
design <- design +
ggplot2::theme(
axis.title.y.right = ggplot2::element_text(
@@ -362,6 +678,8 @@ theme_acdc_light <- function(base_family = set_acdc_font(),
family = axis_title_family, face = axis_title_face
)
)
+
+ ## Set facet label design ----
design <- design +
ggplot2::theme(
strip.text = ggplot2::element_text(
@@ -369,15 +687,21 @@ theme_acdc_light <- function(base_family = set_acdc_font(),
face = strip_text_face, family = strip_text_family
)
)
+
+ ## Set facet spacing design ----
design <- design +
ggplot2::theme(panel.spacing = grid::unit(2, "lines"))
+
+ ## Set plot title design ----
design <- design +
ggplot2::theme(
plot.title = ggplot2::element_text(
- hjust=0, size = plot_title_size, colour = plot_title_colour,
+ hjust = 0, size = plot_title_size, colour = plot_title_colour,
margin = ggplot2::margin(b = plot_title_margin),
family = plot_title_family, face = plot_title_face)
)
+
+ ## Set plot subtitle design ----
design <- design +
ggplot2::theme(
plot.subtitle = ggplot2::element_text(
@@ -386,6 +710,8 @@ theme_acdc_light <- function(base_family = set_acdc_font(),
family = subtitle_family, face = subtitle_face
)
)
+
+ ## Set plot caption design ----
design <- design +
ggplot2::theme(
plot.caption = ggplot2::element_text(
@@ -394,9 +720,12 @@ theme_acdc_light <- function(base_family = set_acdc_font(),
family = caption_family, face = caption_face
)
)
+
+ ## Set plot margin ----
design <- design + ggplot2::theme(plot.margin = plot_margin)
## return design ----
design
}
+
diff --git a/R/motif.R b/R/motif.R
index 394b2e7..92baff7 100644
--- a/R/motif.R
+++ b/R/motif.R
@@ -12,5 +12,10 @@
#' @keywords internal
#' @importFrom stringr str_detect
#' @importFrom systemfonts system_fonts
+#' @importFrom ggplot2 theme element_rect element_line element_text margin
+#' theme_minimal element_blank
+#' @importFrom grid unit
+#' @importFrom grDevices col2rgb rgb colorRampPalette
+#' @importFrom graphics rect par image text
#'
"_PACKAGE"
diff --git a/R/utils.R b/R/utils.R
index e69de29..4b51dfa 100644
--- a/R/utils.R
+++ b/R/utils.R
@@ -0,0 +1,22 @@
+#'
+#' Print function for palettes
+#'
+#' @param x An object of class `palette`
+#' @param ... Additional arguments to print
+#'
+#' @export
+#'
+print.palette <- function(x, ...) {
+ n <- length(x)
+
+ withr::with_par(
+ new = list(mar = c(0.5, 0.5, 0.5, 0.5)),
+ code = {
+ image(1:n, 1, as.matrix(1:n), col = x,
+ ylab = "", xaxt = "n", yaxt = "n", bty = "n")
+
+ rect(0, 0.9, n + 1, 1.1, col = rgb(1, 1, 1, 0.8), border = NA)
+ text((n + 1) / 2, 1, labels = attr(x, "name"), cex = 1, family = "serif")
+ }
+ )
+}
diff --git a/README.Rmd b/README.Rmd
index dbb9c4a..b555d8e 100644
--- a/README.Rmd
+++ b/README.Rmd
@@ -50,9 +50,20 @@ install.packages(
## Usage
-### Africa CDC colours, palettes, and `ggplot2` theme
+### Africa CDC colours and palettes
-```{r mtcars-acdc, fig.align = "center", fig.width = 6, fig.height = 5}
+```{r acdc-primary, echo = FALSE, fig.align = "center", fig.height = 1}
+structure(acdc_palettes$acdc_primary, class = "palette", name = "Africa CDC Primary Colours")
+```
+
+```{r acdc-secondary, echo = FALSE, fig.align = "center", fig.height = 1}
+structure(acdc_palettes$acdc_secondary, class = "palette", name = "Africa CDC Secondary Colours")
+```
+
+### Africa CDC `ggplot2` theme
+
+```{r mtcars-bar-acdc, echo = FALSE, fig.show = "hold", fig.height = 6, out.width = "50%"}
+## theme_acdc_light
ggplot(
data = mtcars,
mapping = aes(
@@ -62,11 +73,50 @@ ggplot(
geom_bar() +
scale_fill_manual(name = "Cylinders", values = acdc_palettes$acdc_secondary) +
labs(
- title = "Plot of mtcars using theme_acdc_light",
+ title = "Light ACDC Theme",
subtitle = "Using the Africa CDC secondary palette",
x = "Engine Shape", y = "Counts"
) +
theme_acdc_light()
+
+## theme_acdc_dark
+ggplot(
+ data = mtcars,
+ mapping = aes(
+ x = factor(vs, levels = c(0, 1), labels = c("v-shaped", "straight")),
+ fill = factor(cyl))
+) +
+ geom_bar() +
+ scale_fill_manual(name = "Cylinders", values = acdc_palettes$acdc_secondary) +
+ labs(
+ title = "Dark ACDC Theme",
+ subtitle = "Using the Africa CDC secondary palette",
+ x = "Engine Shape", y = "Counts"
+ ) +
+ theme_acdc_dark()
+```
+
+
+```{r mtcars-scatter-acdc, echo = FALSE, fig.show = "hold", fig.height = 6, out.width = "50%"}
+## theme_acdc_light
+ggplot(data = mtcars, mapping = aes(x = mpg, y = disp, colour = factor(cyl))) +
+ geom_point(size = 5) +
+ scale_colour_manual(
+ name = "Cylinders",
+ values = acdc_palettes$acdc_secondary
+ ) +
+ labs(title = "mpg by disp grouped by cyl") +
+ theme_acdc_light()
+
+## theme_acdc_dark
+ggplot(data = mtcars, mapping = aes(x = mpg, y = disp, colour = factor(cyl))) +
+ geom_point(size = 5) +
+ scale_colour_manual(
+ name = "Cylinders",
+ values = acdc_palettes$acdc_secondary
+ ) +
+ labs(title = "mpg by disp grouped by cyl") +
+ theme_acdc_dark()
```
## Community guidelines
diff --git a/README.md b/README.md
index 953e145..0032798 100644
--- a/README.md
+++ b/README.md
@@ -49,26 +49,17 @@ install.packages(
## Usage
-### Africa CDC colours, palettes, and `ggplot2` theme
+### Africa CDC colours and palettes
-``` r
-ggplot(
- data = mtcars,
- mapping = aes(
- x = factor(vs, levels = c(0, 1), labels = c("v-shaped", "straight")),
- fill = factor(cyl))
-) +
- geom_bar() +
- scale_fill_manual(name = "Cylinders", values = acdc_palettes$acdc_secondary) +
- labs(
- title = "Plot of mtcars using theme_acdc_light",
- subtitle = "Using the Africa CDC secondary palette",
- x = "Engine Shape", y = "Counts"
- ) +
- theme_acdc_light()
-```
+
+
+
+
+### Africa CDC `ggplot2` theme
+
+
-
+
## Community guidelines
diff --git a/man/figures/README-acdc-primary-1.png b/man/figures/README-acdc-primary-1.png
new file mode 100644
index 0000000..f47806c
Binary files /dev/null and b/man/figures/README-acdc-primary-1.png differ
diff --git a/man/figures/README-acdc-secondary-1.png b/man/figures/README-acdc-secondary-1.png
new file mode 100644
index 0000000..3eead5f
Binary files /dev/null and b/man/figures/README-acdc-secondary-1.png differ
diff --git a/man/figures/README-mtcars-acdc-1.png b/man/figures/README-mtcars-acdc-1.png
index 374f30c..48c57f5 100644
Binary files a/man/figures/README-mtcars-acdc-1.png and b/man/figures/README-mtcars-acdc-1.png differ
diff --git a/man/figures/README-mtcars-acdc-2.png b/man/figures/README-mtcars-acdc-2.png
new file mode 100644
index 0000000..5510917
Binary files /dev/null and b/man/figures/README-mtcars-acdc-2.png differ
diff --git a/man/figures/README-mtcars-bar-acdc-1.png b/man/figures/README-mtcars-bar-acdc-1.png
new file mode 100644
index 0000000..48c57f5
Binary files /dev/null and b/man/figures/README-mtcars-bar-acdc-1.png differ
diff --git a/man/figures/README-mtcars-bar-acdc-2.png b/man/figures/README-mtcars-bar-acdc-2.png
new file mode 100644
index 0000000..5510917
Binary files /dev/null and b/man/figures/README-mtcars-bar-acdc-2.png differ
diff --git a/man/figures/README-mtcars-scatter-acdc-1.png b/man/figures/README-mtcars-scatter-acdc-1.png
new file mode 100644
index 0000000..25f332c
Binary files /dev/null and b/man/figures/README-mtcars-scatter-acdc-1.png differ
diff --git a/man/figures/README-mtcars-scatter-acdc-2.png b/man/figures/README-mtcars-scatter-acdc-2.png
new file mode 100644
index 0000000..5a21a23
Binary files /dev/null and b/man/figures/README-mtcars-scatter-acdc-2.png differ
diff --git a/man/figures/README-unnamed-chunk-2-1.png b/man/figures/README-unnamed-chunk-2-1.png
new file mode 100644
index 0000000..f47806c
Binary files /dev/null and b/man/figures/README-unnamed-chunk-2-1.png differ
diff --git a/man/print.palette.Rd b/man/print.palette.Rd
new file mode 100644
index 0000000..faf67f2
--- /dev/null
+++ b/man/print.palette.Rd
@@ -0,0 +1,16 @@
+% Generated by roxygen2: do not edit by hand
+% Please edit documentation in R/utils.R
+\name{print.palette}
+\alias{print.palette}
+\title{Print function for palettes}
+\usage{
+\method{print}{palette}(x, ...)
+}
+\arguments{
+\item{x}{An object of class `palette`}
+
+\item{...}{Additional arguments to print}
+}
+\description{
+Print function for palettes
+}
diff --git a/man/theme_acdc.Rd b/man/theme_acdc.Rd
index f914b90..285deeb 100644
--- a/man/theme_acdc.Rd
+++ b/man/theme_acdc.Rd
@@ -2,6 +2,7 @@
% Please edit documentation in R/africa_cdc.R
\name{theme_acdc_light}
\alias{theme_acdc_light}
+\alias{theme_acdc_dark}
\title{A [ggplot2] theme using Africa CDC fonts, colours, and palettes}
\usage{
theme_acdc_light(
@@ -23,7 +24,7 @@ theme_acdc_light(
caption_family = base_family,
caption_size = 9,
caption_face = "italic",
- caption_colour = acdc_green,
+ caption_colour = acdc_gold,
caption_margin = 10,
axis_text_size = base_size,
axis_title_family = subtitle_family,
@@ -38,38 +39,126 @@ theme_acdc_light(
axis = FALSE,
ticks = FALSE
)
+
+theme_acdc_dark(
+ base_family = set_acdc_font(),
+ base_size = 11.5,
+ plot_title_family = base_family,
+ plot_title_size = 18,
+ plot_title_face = "bold",
+ plot_title_colour = acdc_green,
+ plot_title_margin = 10,
+ subtitle_family = base_family,
+ subtitle_size = 12,
+ subtitle_face = "plain",
+ subtitle_colour = acdc_black,
+ subtitle_margin = 15,
+ strip_text_family = base_family,
+ strip_text_size = 12,
+ strip_text_face = "plain",
+ caption_family = base_family,
+ caption_size = 9,
+ caption_face = "italic",
+ caption_colour = acdc_black,
+ caption_margin = 10,
+ axis_text_size = base_size,
+ axis_title_family = subtitle_family,
+ axis_title_size = 9,
+ axis_title_colour = acdc_black,
+ axis_title_face = "plain",
+ axis_title_just = "rt",
+ plot_margin = ggplot2::margin(30, 30, 30, 30),
+ grid_col = acdc_green,
+ grid = TRUE,
+ axis_col = acdc_green,
+ axis = FALSE,
+ ticks = FALSE
+)
}
\arguments{
-\item{base_family}{Base font family. Default is set by what is available in
-the sytem via `set_acdc_font()`.}
+\item{base_family}{Base font family using Africa CDC fonts. Default is set
+by what Africa CDC font is available in the sytem via `set_acdc_font()`. If
+none of the Africa CDC fonts are available, the default becomes Noto Sans.}
+
+\item{base_size}{Base font size. Default is 11.5.}
+
+\item{plot_title_family}{Font family to use for the plot title. Default is
+`base_family`.}
+
+\item{plot_title_size}{Plot title text size in pts. Default is 18.}
+
+\item{plot_title_face}{Font face ("plain", "italic", "bold", "bold.italic")
+for plot title. Default is "bold".}
+
+\item{plot_title_colour}{Colour of the plot title text. Default
+is `acdc_green`.}
+
+\item{plot_title_margin}{Margin at the bottom of the plot title. Default
+set at 10.}
+
+\item{subtitle_family}{Font family to use for the plot subtitle. Default is
+`base_family`.}
+
+\item{subtitle_size}{Plot subtitle text size in pts. Default is 12.}
+
+\item{subtitle_face}{Font face ("plain", "italic", "bold", "bold.italic")
+for plot subtitle. Default is "plain".}
+
+\item{subtitle_colour}{Colour of the subtitle text. Default is `acdc_gold`.}
+
+\item{subtitle_margin}{Margin at the bottom of the plot subtitle. Default
+set at 15.}
+
+\item{strip_text_family}{Font family to use for the facet label. Default is
+`base_family`.}
+
+\item{strip_text_size}{Facet label text size in pts. Default is 12.}
+
+\item{strip_text_face}{Font face ("plain", "italic", "bold", "bold.italic")
+for facet label. Default is "plain".}
+
+\item{caption_family}{Font family to use for the caption text. Default is
+`base_family`.}
+
+\item{caption_size}{Caption text size in pts. Default is 9.}
+
+\item{caption_face}{Font face ("plain", "italic", "bold", "bold.italic") for
+caption text. Default is "plain".}
-\item{base_size}{Base font size. Default is 11.5}
+\item{caption_colour}{Colour of the caption text. Default is `acdc_gold`.}
-\item{plot_title_family, plot_title_face, plot_title_size, plot_title_margin, plot_title_colour}{plot title family, face, size and margi}
+\item{caption_margin}{Margin at the top of the plot caption text. Default is
+set at 10.}
-\item{subtitle_family, subtitle_face, subtitle_size, subtitle_colour}{plot subtitle family, face and size}
+\item{axis_text_size}{Axis text size in pts. Default is `base_size`.}
-\item{subtitle_margin}{plot subtitle margin bottom (single numeric value)}
+\item{axis_title_family}{Font family to use for the axis title. Default is
+`base_family`.}
-\item{strip_text_family, strip_text_face, strip_text_size}{facet label font family, face and size}
+\item{axis_title_size}{Axis title text size in pts. Default is 9.}
-\item{caption_family, caption_face, caption_size, caption_margin, caption_colour}{plot caption family, face, size and margin}
+\item{axis_title_colour}{Colour of the axis title text. Default is
+`acdc_gold`.}
-\item{axis_text_size}{font size of axis text}
+\item{axis_title_face}{Font face ("plain", "italic", "bold", "bold.italic")
+for axis title. Default is "plain".}
-\item{axis_title_family, axis_title_face, axis_title_size, axis_title_colour}{axis title font family, face and size}
+\item{axis_title_just}{Axis title font justification, one of
+"bl" (bottom-left), "m" (middle), "rt" (right-top). Default is "rt".}
-\item{axis_title_just}{axis title font justification, one of `[blmcrt]`}
+\item{plot_margin}{Plot margins (specify with `ggplot2::margin()`)}
-\item{plot_margin}{plot margin (specify with `ggplot2::margin()`)}
+\item{grid_col}{Grid colour. Default to `acdc_gold`.}
-\item{grid_col, axis_col}{grid & axis colors; both default to `#cccccc`}
+\item{grid}{Panel grid. Either `TRUE`, `FALSE`, or a combination of
+`X` (major x grid), `x` (minor x grid), `Y` (major y grid), and/or
+`y` (minor y grid). Default is TRUE.}
-\item{grid}{panel grid (`TRUE`, `FALSE`, or a combination of `X`, `x`, `Y`, `y`)}
+\item{axis_col}{Axis colors. Default to `acdc_gold`.}
-\item{axis}{add x or y axes? `TRUE`, `FALSE`, "`xy`"}
+\item{axis}{Add x or y axes? `TRUE`, `FALSE`, "`xy`". Default is FALSE.}
-\item{ticks}{ticks if `TRUE` add ticks}
+\item{ticks}{Logical. Should ticks be added? Default is FALSE.}
}
\value{
A [ggplot2] theme.