From ef0b49909b6518d714ecb7e272b16c11633b94eb Mon Sep 17 00:00:00 2001 From: hollway Date: Thu, 2 Nov 2023 11:16:08 +0100 Subject: [PATCH] Consolidated scales documentation into themes --- R/map_theme.R | 22 ++++++++---------- man/scales.Rd | 54 -------------------------------------------- man/themes.Rd | 38 +++++++++++++++++++++++++++++++ pkgdown/_pkgdown.yml | 1 + 4 files changed, 48 insertions(+), 67 deletions(-) delete mode 100644 man/scales.Rd diff --git a/R/map_theme.R b/R/map_theme.R index 3840c327..f1fe77f4 100644 --- a/R/map_theme.R +++ b/R/map_theme.R @@ -112,8 +112,7 @@ palette_gen <- function(palette = "IHEID", direction = 1) { } } -#' IHEID color scales -#' @name scales +#' @rdname themes #' @param palette Name of the palette. Current choices are: #' \code{IHEID}, \code{Centres}, and \code{SDGs}. #' @param direction Direction for using palette colors. @@ -123,62 +122,59 @@ palette_gen <- function(palette = "IHEID", direction = 1) { #' #mutate(core = migraph::node_is_core(ison_brandes)) %>% #' #autographr(node_color = "core") + #' #scale_color_iheid() -NULL - -#' @rdname scales #' @export scale_fill_iheid <- function(palette = "IHEID", direction = 1, ...) { ggplot2::discrete_scale("fill", "IHEID", palette_gen(palette, direction), ...) } -#' @rdname scales +#' @rdname themes #' @export scale_colour_iheid <- function(palette = "IHEID", direction = 1, ...) { ggplot2::discrete_scale("colour", "IHEID", palette_gen(palette, direction), ...) } -#' @rdname scales +#' @rdname themes #' @export scale_color_iheid <- scale_colour_iheid #' Centres color scales #' -#' @rdname scales +#' @rdname themes #' @export scale_fill_centres <- function(palette = "Centres", direction = 1, ...) { ggplot2::discrete_scale("fill", "Centres", palette_gen(palette, direction), ...) } -#' @rdname scales +#' @rdname themes #' @export scale_colour_centres <- function(palette = "Centres", direction = 1, ...) { ggplot2::discrete_scale("colour", "Centres", palette_gen(palette, direction), ...) } -#' @rdname scales +#' @rdname themes #' @export scale_color_centres <- scale_colour_centres #' SDGs color scales #' -#' @rdname scales +#' @rdname themes #' @export scale_fill_sdgs <- function(palette = "SDGs", direction = 1, ...) { ggplot2::discrete_scale("fill", "SDGs", palette_gen(palette, direction), ...) } -#' @rdname scales +#' @rdname themes #' @export scale_colour_sdgs <- function(palette = "SDGs", direction = 1, ...) { ggplot2::discrete_scale("colour", "SDGs", palette_gen(palette, direction), ...) } -#' @rdname scales +#' @rdname themes #' @export scale_color_sdgs <- scale_colour_sdgs diff --git a/man/scales.Rd b/man/scales.Rd deleted file mode 100644 index 5a758d0d..00000000 --- a/man/scales.Rd +++ /dev/null @@ -1,54 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/map_theme.R -\name{scales} -\alias{scales} -\alias{scale_fill_iheid} -\alias{scale_colour_iheid} -\alias{scale_color_iheid} -\alias{scale_fill_centres} -\alias{scale_colour_centres} -\alias{scale_color_centres} -\alias{scale_fill_sdgs} -\alias{scale_colour_sdgs} -\alias{scale_color_sdgs} -\title{IHEID color scales} -\usage{ -scale_fill_iheid(palette = "IHEID", direction = 1, ...) - -scale_colour_iheid(palette = "IHEID", direction = 1, ...) - -scale_color_iheid(palette = "IHEID", direction = 1, ...) - -scale_fill_centres(palette = "Centres", direction = 1, ...) - -scale_colour_centres(palette = "Centres", direction = 1, ...) - -scale_color_centres(palette = "Centres", direction = 1, ...) - -scale_fill_sdgs(palette = "SDGs", direction = 1, ...) - -scale_colour_sdgs(palette = "SDGs", direction = 1, ...) - -scale_color_sdgs(palette = "SDGs", direction = 1, ...) -} -\arguments{ -\item{palette}{Name of the palette. Current choices are: -\code{IHEID}, \code{Centres}, and \code{SDGs}.} - -\item{direction}{Direction for using palette colors.} - -\item{...}{Extra arguments passed to \code{ggplot2::discrete_scale()}.} -} -\description{ -IHEID color scales - -Centres color scales - -SDGs color scales -} -\examples{ -#ison_brandes \%>\% -#mutate(core = migraph::node_is_core(ison_brandes)) \%>\% -#autographr(node_color = "core") + -#scale_color_iheid() -} diff --git a/man/themes.Rd b/man/themes.Rd index d8ac5b11..e7af07b2 100644 --- a/man/themes.Rd +++ b/man/themes.Rd @@ -3,14 +3,48 @@ \name{themes} \alias{themes} \alias{theme_iheid} +\alias{scale_fill_iheid} +\alias{scale_colour_iheid} +\alias{scale_color_iheid} +\alias{scale_fill_centres} +\alias{scale_colour_centres} +\alias{scale_color_centres} +\alias{scale_fill_sdgs} +\alias{scale_colour_sdgs} +\alias{scale_color_sdgs} \title{Many themes} \usage{ theme_iheid(base_size = 12, base_family = "sans") + +scale_fill_iheid(palette = "IHEID", direction = 1, ...) + +scale_colour_iheid(palette = "IHEID", direction = 1, ...) + +scale_color_iheid(palette = "IHEID", direction = 1, ...) + +scale_fill_centres(palette = "Centres", direction = 1, ...) + +scale_colour_centres(palette = "Centres", direction = 1, ...) + +scale_color_centres(palette = "Centres", direction = 1, ...) + +scale_fill_sdgs(palette = "SDGs", direction = 1, ...) + +scale_colour_sdgs(palette = "SDGs", direction = 1, ...) + +scale_color_sdgs(palette = "SDGs", direction = 1, ...) } \arguments{ \item{base_size}{Font size, by default 12.} \item{base_family}{Font family, by default "sans".} + +\item{palette}{Name of the palette. Current choices are: +\code{IHEID}, \code{Centres}, and \code{SDGs}.} + +\item{direction}{Direction for using palette colors.} + +\item{...}{Extra arguments passed to \code{ggplot2::discrete_scale()}.} } \value{ Themes the current ggraph to current IHEID guidelines. @@ -23,4 +57,8 @@ e.g. changing the default colour of the graph's vertices and edges. # autographr(to_mentoring(ison_brandes)) + # labs(title = "Who leads and who follows?") + # theme_iheid() +#ison_brandes \%>\% +#mutate(core = migraph::node_is_core(ison_brandes)) \%>\% +#autographr(node_color = "core") + +#scale_color_iheid() } diff --git a/pkgdown/_pkgdown.yml b/pkgdown/_pkgdown.yml index b6c8eb04..f41a5959 100644 --- a/pkgdown/_pkgdown.yml +++ b/pkgdown/_pkgdown.yml @@ -78,6 +78,7 @@ reference: - starts_with("autograph") - starts_with("layout") - starts_with("theme") + - ends_with("palette") - title: "Data" desc: | The package contains a variety of networks useful for pedagogical purposes