Skip to content

Commit

Permalink
lintr
Browse files Browse the repository at this point in the history
  • Loading branch information
strengejacke committed Oct 25, 2024
1 parent 77c0a03 commit 6227a46
Show file tree
Hide file tree
Showing 10 changed files with 213 additions and 50 deletions.
4 changes: 1 addition & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ Authors@R:
person(given = "Matthew",
family = "Smith",
role = "rev",
email = "[email protected]",
comment = c(Twitter = "@SmithMatt90")),
email = "[email protected]"),
person(given = "Jakob",
family = "Bossek",
role = "rev",
Expand Down Expand Up @@ -121,4 +120,3 @@ Config/testthat/edition: 3
Config/testthat/parallel: true
Config/Needs/website: easystats/easystatstemplate
Config/rcmdcheck/ignore-inconsequential-notes: true
Remotes: easystats/performance, easystats/parameters
5 changes: 5 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ export(palette_okabeito)
export(palette_pizza)
export(palette_see)
export(palette_social)
export(palette_tol_discrete)
export(pizza_colors)
export(plots)
export(scale_color_bluebrown)
Expand Down Expand Up @@ -138,6 +139,7 @@ export(scale_color_see_d)
export(scale_color_social)
export(scale_color_social_c)
export(scale_color_social_d)
export(scale_color_tol_discrete)
export(scale_colour_bluebrown)
export(scale_colour_bluebrown_c)
export(scale_colour_bluebrown_d)
Expand All @@ -164,6 +166,7 @@ export(scale_colour_see_d)
export(scale_colour_social)
export(scale_colour_social_c)
export(scale_colour_social_d)
export(scale_colour_tol_discrete)
export(scale_fill_bluebrown)
export(scale_fill_bluebrown_c)
export(scale_fill_bluebrown_d)
Expand All @@ -190,6 +193,7 @@ export(scale_fill_see_d)
export(scale_fill_social)
export(scale_fill_social_c)
export(scale_fill_social_d)
export(scale_fill_tol_discrete)
export(see_colors)
export(social_colors)
export(theme_abyss)
Expand All @@ -198,4 +202,5 @@ export(theme_lucid)
export(theme_modern)
export(theme_radar)
export(theme_radar_dark)
export(tol_colors)
import(ggplot2)
31 changes: 16 additions & 15 deletions R/scale_color_okabeito.R
Original file line number Diff line number Diff line change
Expand Up @@ -101,22 +101,23 @@ scale_fill_oi <- scale_fill_okabeito
# Palette --------------------------------------------------------------------

# The palette from: https://jfly.uni-koeln.de/color/#pallet
# or grDevices::palette.colors()
okabeito_colors_list <- c(
`orange` = "#E69F00",
orange = "#E69F00",
`light blue` = "#56B4E9",
`green` = "#009E73",
`yellow` = "#F0E442",
`blue` = "#0072B2",
`red` = "#D55E00",
`purple` = "#CC79A7",
`grey` = "#999999",
`black` = "#000000",
green = "#009E73",
yellow = "#F0E442",
blue = "#0072B2",
red = "#D55E00",
purple = "#CC79A7",
grey = "#999999",
black = "#000000",
`sky blue` = "#56B4E9",
`bluish green` = "#009E73",
`vermillion` = "#D55E00",
vermillion = "#D55E00",
`reddish purple` = "#CC79A7",
`dark yellow` = "#F5C710",
`amber` = "#F5C710"
amber = "#F5C710"
)


Expand Down Expand Up @@ -171,10 +172,10 @@ okabeito_colors <- function(..., original_names = FALSE, black_first = FALSE, am
oi_colors <- okabeito_colors

okabeito_palettes <- list(
`full` = okabeito_colors(black_first = FALSE, amber = TRUE),
`black_first` = okabeito_colors(black_first = TRUE, amber = TRUE),
`full_original` = okabeito_colors(black_first = FALSE, amber = FALSE),
`black_original` = okabeito_colors(black_first = TRUE, amber = FALSE)
full = okabeito_colors(black_first = FALSE, amber = TRUE),
black_first = okabeito_colors(black_first = TRUE, amber = TRUE),
full_original = okabeito_colors(black_first = FALSE, amber = FALSE),
black_original = okabeito_colors(black_first = TRUE, amber = FALSE)
)


Expand Down Expand Up @@ -210,7 +211,7 @@ palette_okabeito <- function(palette = "full_amber", reverse = FALSE, order = 1:

stopifnot(
"`order` must be a vector of integers." = is.numeric(order),
"All elements of `order` must be greater than 0 and less than 10." = all(order > 0 & order <= 9)
"All elements of `order` must be greater than 0 and less than 10." = order > 0 & order <= 9
)
pal <- pal[order]

Expand Down
39 changes: 15 additions & 24 deletions R/scale_color_tol.R
Original file line number Diff line number Diff line change
Expand Up @@ -102,25 +102,25 @@ tol_colors_discrete_list <- list(
dark = c(blue = "#222255", cyan = "#225555", green = "#225522", yellow = "#666633", red = "#663333", grey = "#555555"),
light = c(blue = "#77AADD", orange = "#EE8866", yellow = "#EEDD88", pink = "#FFAABB", cyan = "#99DDFF", mint = "#44BB99", pear = "#BBCC33", olive = "#AAAA00", grey = "#DDDDDD"),
# TODO: Finish rainbow color schemes
rainbow14 = c('3', '6', '9', '10', '12', '14', '15', '16', '17', '18', '20', '22', '24', '26' = "#DC050C", 'grey'),
rainbow23 = c('1', '2', '4', '5', '7', '8', '9', '10', '11', '13', '14', '15', '16', '17', '18', '19', '21', '23', '25', '26' = "#DC050C", '27' = "#A5170E", '28' = "#72190E", '29' = "#42150A", 'grey' = '#777777'),
rainbow14 = c("3", "6", "9", "10", "12", "14", "15", "16", "17", "18", "20", "22", "24", "26" = "#DC050C", "grey"),
rainbow23 = c("1", "2", "4", "5", "7", "8", "9", "10", "11", "13", "14", "15", "16", "17", "18", "19", "21", "23", "25", "26" = "#DC050C", "27" = "#A5170E", "28" = "#72190E", "29" = "#42150A", grey = "#777777"),
ground_cover = c(
water = "#5566AA", "evergreen needleleaf forest" = "#117733", "deciduous needleleaf forest" = "#44AA66",
"mixed forest" = "#55AA22", "evergreen broadleaf forest" = "#668822", "deciduous broadleaf forest" = "#88BB55",
"woodland" = "#558877", "wooded grassland" = "#88BBAA", "grassland" = "#AADDCC", "cropland" = "#44AA88",
woodland = "#558877", "wooded grassland" = "#88BBAA", grassland = "#AADDCC", cropland = "#44AA88",
"closed shrubland" = "#DDCC66", "open shrubland" = "#FFDD44", "bare ground" = "#FFEE88", "urband and built up" = "#BB0011"
)
)

tol_colors_smooth_list <- list(
# Diverging
sunset = c("#"),
BuRd = c(),
PRGn = c(),
sunset = "#",
BuRd = NULL,
PRGn = NULL,
# Sequential
YlOrBr = c(),
iridescent = c(),
rainbow = c()
YlOrBr = NULL,
iridescent = NULL,
rainbow = NULL
)


Expand All @@ -132,9 +132,11 @@ tol_colors_smooth_list <- list(
#'
#' @param ... Character names of colors.
#' @param palette Character name of palette. Can be:
#' - Qualitative: `"bright"`, `"high-contrast"`, `"vibrant"`, `"muted"`,` "medium-contrast"`, `"pale"`, `"dark"`, `"light"`, `"ground_cover"`
#' - Qualitative: `"bright"`, `"high-contrast"`, `"vibrant"`, `"muted"`,`
#' "medium-contrast"`, `"pale"`, `"dark"`, `"light"`, `"ground_cover"`
#' - Diverging: `"sunset"`, `"BuRd"`, `"PRGn"`
#' - Sequential: `"YlOrBr"`, `"iridescent"`, `"rainbow_discrete"`, `"rainbow_smooth"`
#' - Sequential: `"YlOrBr"`, `"iridescent"`, `"rainbow_discrete"`,
#' `"rainbow_smooth"`
#'
#' @return A character vector with color-codes.
#'
Expand Down Expand Up @@ -167,17 +169,6 @@ tol_colors <- function(..., palette = "bright") {
okabeito_colors_list[cols]
}

#' @rdname okabeito_colors
#' @export
oi_colors <- okabeito_colors

okabeito_palettes <- list(
`full` = okabeito_colors(black_first = FALSE, amber = TRUE),
`black_first` = okabeito_colors(black_first = TRUE, amber = TRUE),
`full_original` = okabeito_colors(black_first = FALSE, amber = FALSE),
`black_original` = okabeito_colors(black_first = TRUE, amber = FALSE)
)


#' Paul Tol's color palettes
#'
Expand All @@ -189,7 +180,7 @@ okabeito_palettes <- list(
#' - Sequential: `"YlOrBr"`, `"iridescent"`, `"rainbow_discrete"`, `"rainbow_smooth"`
#' @param reverse Boolean indicating whether the palette should be reversed.
#' @param order A vector of numbers indicating the order of colors to use (default: `NULL` indicating to use all available colors in order).
#' @parem ... For sequential palettes other than `rainbow_discrete`, additional arguments to pass to [`colorRampPalette()`][colorRampPalette].
#' @param ... For sequential palettes other than `rainbow_discrete`, additional arguments to pass to [`colorRampPalette()`][colorRampPalette].
#'
#' @references
#' Tol, P. (2021). Colour schemes (SRON/EPS Technical Note No. 09-002; Version 3.2).
Expand All @@ -214,7 +205,7 @@ palette_tol_discrete <- function(palette = "bright", reverse = FALSE, order = NU

stopifnot(
"`order` must be a vector of integers." = is.numeric(order),
"All elements of `order` must be greater than 0 and less than 10." = all(order > 0 & order <= 9)
"All elements of `order` must be greater than 0 and less than 10." = order > 0 & order <= 9
)
pal <- pal[order]

Expand Down
4 changes: 2 additions & 2 deletions man/palette_okabeito.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 33 additions & 0 deletions man/palette_tol_discrete.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions man/scale_color_okabeito.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

98 changes: 98 additions & 0 deletions man/scale_color_tol_discrete.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions man/see-package.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 6227a46

Please sign in to comment.