diff --git a/.Rbuildignore b/.Rbuildignore index 40d341c..679313f 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -5,3 +5,4 @@ ^\.github$ ^cran-comments\.md$ ^CRAN-RELEASE$ +^CRAN-SUBMISSION$ diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index a3ac618..5ca5022 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -5,38 +5,22 @@ on: branches: [main, master] pull_request: branches: [main, master] + schedule: + - cron: '00 1 * * 1' name: R-CMD-check jobs: R-CMD-check: - runs-on: ${{ matrix.config.os }} - - name: ${{ matrix.config.os }} (${{ matrix.config.r }}) - - strategy: - fail-fast: false - matrix: - config: - - {os: macos-latest, r: 'release'} - - {os: windows-latest, r: 'release'} - - {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'} - - {os: ubuntu-latest, r: 'release'} - - {os: ubuntu-latest, r: 'oldrel-1'} - + runs-on: ubuntu-latest env: GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} R_KEEP_PKG_SOURCE: yes - steps: - uses: actions/checkout@v3 - - uses: r-lib/actions/setup-pandoc@v2 - - uses: r-lib/actions/setup-r@v2 with: - r-version: ${{ matrix.config.r }} - http-user-agent: ${{ matrix.config.http-user-agent }} use-public-rspm: true - uses: r-lib/actions/setup-r-dependencies@v2 @@ -45,5 +29,3 @@ jobs: needs: check - uses: r-lib/actions/check-r-package@v2 - with: - upload-snapshots: true diff --git a/CRAN-SUBMISSION b/CRAN-SUBMISSION new file mode 100644 index 0000000..9f762ec --- /dev/null +++ b/CRAN-SUBMISSION @@ -0,0 +1,4 @@ +Version: 0.1.4 +Date: 2023-09-07 19:55:56 UTC +SHA: + d0cf9e1372771e89b74a37c0ea69e75934b91d26 diff --git a/DESCRIPTION b/DESCRIPTION index 02ad495..e17f32a 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: colorhex Type: Package Title: Colors and Palettes from Color-Hex -Version: 0.1.2 +Version: 0.1.4 Authors@R: c( person("Athanasia Mo", "Mowinckel", email = "a.m.mowinckel@psykologi.uio.no", @@ -19,14 +19,16 @@ Description: The website is a great resource of hex License: MIT + file LICENSE Encoding: UTF-8 Imports: - rvest, - xml2, - grDevices, + cli, + curl, + ggplot2, graphics, - ggplot2 -RoxygenNote: 7.1.1 -URL: https://github.com/Athanasiamo/colorhex -BugReports: https://github.com/Athanasiamo/colorhex/issues + grDevices, + httr2, + rvest +RoxygenNote: 7.2.3 +URL: https://github.com/drmowinckels/colorhex +BugReports: https://github.com/drmowinckels/colorhex/issues Suggests: spelling, scales diff --git a/NEWS.md b/NEWS.md index 75ae404..8d712ad 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,7 @@ + +# colorhex 0.1.4 +- fixes failure of build if server is unresponsive + # colorhex 0.1.1 - cran submission diff --git a/R/api.R b/R/api.R new file mode 100644 index 0000000..7c2f7c8 --- /dev/null +++ b/R/api.R @@ -0,0 +1,35 @@ +query_colorhex <- function(){ + if(!curl::has_internet()){ + cli::cli_alert_warning("Not connected to internet.") + return(invisible(NULL)) + } + req <- httr2::request(colour_url()) + req <- httr2::req_retry(req, + backoff = ~ 10, + is_transient = ~ httr2::resp_status(.x) > 400) + req <- httr2::req_error(req, + is_error = function(resp) FALSE, + body = error_body) + req +} + +colour_url <- function(full = TRUE){ + url <- "www.color-hex.com" + if(!full) + return(url) + paste0("https://", url, "/") +} + +error_body <- function(resp) { + httr2::resp_body_json(resp)$error +} + +status_ok <- function(req){ + test <- httr2::req_perform(req) + if(httr2::resp_status(test) > 400 ){ + cli::cli_alert_warning("Cannot connect to service.") + cli::cli_inform(httr2::resp_status_desc(test)) + return(FALSE) + } + TRUE +} diff --git a/R/color.R b/R/color.R index 06b7965..0e43285 100644 --- a/R/color.R +++ b/R/color.R @@ -8,13 +8,24 @@ #' @export #' #' @examples +#' if(curl::has_internet()){ #' get_popular_colors() +#' } get_popular_colors <- function(){ - url <- paste0(colour_url(), "popular-colors.php") - resp <- xml2::read_html(url) - - cols <- rvest::html_nodes(resp, - xpath = '//*[@class="colordva"]') + req <- httr2::request(colour_url()) + if(is.null(req)) + return(invisible(NULL)) + req <- httr2::req_url_path_append( + req, + "popular-colors.php") + if(!status_ok(req)) + return(invisible(NULL)) + + resp <- httr2::req_perform(req) + resp <- httr2::resp_body_html(resp) + cols <- rvest::html_nodes( + resp, + xpath = '//*[@class="colordva"]') cols <- as.character(cols) get_bkg_color(cols) } @@ -33,10 +44,6 @@ get_random_color <- function(){ maxColorValue = 255) } -randcol <- function(){ - sample(1:255, 1) -} - #' Get color information #' #' Get color information from www.color-hex.com @@ -48,19 +55,28 @@ randcol <- function(){ #' @export #' #' @examples +#' if(curl::has_internet()){ #' get_color("#470f0f") -#' get_color("#f2f2f2") +#' } get_color <- function(hex){ hex <- fix_hex(hex) - stopifnot(is_hex(hex)) + req <- query_colorhex() + if(is.null(req)) + return(invisible(NULL)) - url <- paste0(colour_url(), "color/", gsub("#", "", hex)) + req <- httr2::req_url_path_append( + req, + "color", + gsub("^#", "", hex)) - resp <- xml2::read_html(url) - tables <- rvest::html_nodes(resp, "table") + if(!status_ok(req)) + return(invisible(NULL)) - prim <- rvest::html_table(tables[1], fill = TRUE)[[1]] - prim <- as.data.frame(t(prim)) + resp <- httr2::req_perform(req) + resp <- httr2::resp_body_html(resp) + tables <- rvest::html_nodes(resp, "table") + tables <- lapply(tables, rvest::html_table, fill = TRUE) + prim <- as.data.frame(t(tables[[1]])) names(prim) <- as.character(unlist(prim[1,])) row.names(prim) <- NULL prim <- prim[-1,] @@ -69,12 +85,12 @@ get_color <- function(hex){ xpath = '//*[@class="colordvconline"]') rows <- rvest::html_text(rows) rows <- gsub(" \n", "", rows) - rows <- fix_hex(rows) + rows <- sapply(rows, fix_hex) ret <- list( hex = hex, space = prim, - base = rvest::html_table(tables[2], fill = TRUE)[[1]], + base = tables[[2]], triadic = NA_character_, analogous = NA_character_, complementary = NA_character_, @@ -85,9 +101,13 @@ get_color <- function(hex){ ) if(length(tables) > 2){ - ret$triadic = fix_hex(chartable(tables[3])) - ret$analogous = fix_hex(chartable(tables[4])) - ret$complementary = fix_hex(chartable(tables[5])) + ex <- lapply(3:5, function(x){ + j <- unique(unlist(tables[[x]])) + sapply(j[j!=""], fix_hex) + }) + ret$triadic = ex[[1]] + ret$analogous = ex[[2]] + ret$complementary = ex[[3]] } colorhex(ret) diff --git a/R/palette.R b/R/palette.R index 6bca257..79b0b7a 100644 --- a/R/palette.R +++ b/R/palette.R @@ -7,45 +7,49 @@ #' @export #' #' @examples +#' if(curl::has_internet()){ #' get_latest_palettes() +#' } get_latest_palettes <- function(){ - url <- paste0(colour_url(), "color-palettes/") - resp <- xml2::read_html(url) + req <- query_colorhex() + if(is.null(req)) + return(invisible(NULL)) + req <- httr2::req_url_path_append( + req, "color-palettes") + if(!status_ok(req)) + return(invisible(NULL)) + resp <- httr2::req_perform(req) + resp <- httr2::resp_body_html(resp) get_pals(resp) } #' Get most popular palettes #' #' Retrieve the palettes most users have -#' checked as favourites from www.color-hex.com +#' checked as favorites from www.color-hex.com #' #' @return data.frame with name, id and colours #' @export #' #' @examples +#' if(curl::has_internet()){ #' get_popular_palettes() +#' } get_popular_palettes <- function(){ - url <- paste0(colour_url(), "color-palettes/popular.php") - resp <- xml2::read_html(url) + req <- query_colorhex() + if(is.null(req)) + return(invisible(NULL)) + req <- httr2::req_url_path_append( + req, + "color-palettes", + "popular.php") + if(!status_ok(req)) + return(invisible(NULL)) + resp <- httr2::req_perform(req) + resp <- httr2::resp_body_html(resp) get_pals(resp) } -get_pal <- function(id){ - url <- paste0(colour_url(), "color-palette/", id) - resp <- xml2::read_html(url) - - tables <- rvest::html_nodes(resp, "table") - tables <- rvest::html_table(tables[1], fill = TRUE)[[1]] - - - palettehex( - gsub(" Color Palette", "", - rvest::html_text(rvest::html_nodes(resp, "h1"))), - id, - list(tables[,2]) - ) -} - #' Get palettes from id #' #' Get palette information from www.color-hex.com @@ -57,11 +61,13 @@ get_pal <- function(id){ #' @export #' #' @examples +#' if(curl::has_internet()){ #' get_palette(103107) #' #' # Lookup multiple palettes #' id <- c(103161, 103107) #' get_palette(id) +#' } get_palette <- function(id){ x <- lapply(id, get_pal) do.call(rbind, x) @@ -95,6 +101,31 @@ plot.palettehex <- function(x, ...){ } # helpers ---- + +get_pal <- function(id){ + req <- query_colorhex() + if(is.null(req)) + return(invisible(NULL)) + req <- httr2::req_url_path_append( + req, + "color-palette", + id) + if(!status_ok(req)) + return(invisible(NULL)) + resp <- httr2::req_perform(req) + resp <- httr2::resp_body_html(resp) + + tables <- rvest::html_nodes(resp, "table") + tables <- rvest::html_table(tables[1], fill = TRUE)[[1]] + + palettehex( + gsub(" Color Palette", "", + rvest::html_text(rvest::html_nodes(resp, "h1"))), + id, + list(tables[,2]) + ) +} + get_pals <- function(resp, class = "palettecontainerlist"){ path <- paste0('//*[@class="',class, '"]') pal <- rvest::html_nodes(resp, xpath = path) diff --git a/R/scale_colorhex.R b/R/scale_colorhex.R index 121a6d2..cdd02e9 100644 --- a/R/scale_colorhex.R +++ b/R/scale_colorhex.R @@ -18,6 +18,7 @@ #' @name scale-colorhex #' @return a ggplot2-proto #' @examples +#' if(curl::has_internet()){ #' library(ggplot2) #' #' x <- get_color("#008080") @@ -41,6 +42,7 @@ #' ggplot(mtcars, aes(mpg, disp, colour = factor(cyl))) + #' geom_point() + #' scale_color_colorhex_d(x, "shades") +#' } NULL #> NULL diff --git a/R/scale_palettehex.R b/R/scale_palettehex.R index 619eb87..44333a7 100644 --- a/R/scale_palettehex.R +++ b/R/scale_palettehex.R @@ -17,6 +17,7 @@ #' @name scale-palettehex #' @return ggplot2-proto #' @examples +#' if(curl::has_internet()){ #' library(ggplot2) #' #' x <- get_popular_palettes() @@ -36,6 +37,7 @@ #' ggplot(mtcars, aes(mpg, disp, colour = factor(cyl))) + #' geom_point() + #' scale_color_palettehex_d(x, 1872) +#' } NULL #> NULL diff --git a/R/utils.R b/R/utils.R index 83196dc..e34308e 100644 --- a/R/utils.R +++ b/R/utils.R @@ -13,11 +13,6 @@ is_hex <- function(x){ } -colour_url <- function(){ - "https://www.color-hex.com/" -} - - chartable <- function(table){ x <- rvest::html_table(table)[[1]] as.character(x[-1, ])[-1] @@ -25,7 +20,7 @@ chartable <- function(table){ strip_html <- function(x){ rvest::html_text( - xml2::read_html(x) + rvest::read_html(x) ) } @@ -43,10 +38,13 @@ get_bkg_color <- function(x){ x <- sapply(x, function(x) x[2]) x <- gsub(';|\\\">|| ', '', x) - fix_hex(x) + sapply(x, fix_hex) } fix_hex <- function(x){ + if(!is_hex(x)){ + cli::cli_abort("'{x}' is not a valid hexidecimal colour.") + } indx <- ifelse(nchar(x) == 4, TRUE, FALSE) x[indx] <- paste0(x[indx], gsub("#", "", x[indx])) @@ -58,3 +56,7 @@ nchar <- function(x){ j <- lapply(j, length) unlist(j) } + +randcol <- function(){ + sample(1:255, 1) +} diff --git a/README.Rmd b/README.Rmd index 9852ad2..2300b7e 100644 --- a/README.Rmd +++ b/README.Rmd @@ -18,8 +18,7 @@ knitr::opts_chunk$set( [![CRAN status](https://www.r-pkg.org/badges/version/colorhex)](https://CRAN.R-project.org/package=colorhex) -[![R-CMD-check](https://github.com/Athanasiamo/colorhex/workflows/R-CMD-check/badge.svg)](https://github.com/Athanasiamo/colorhex/actions) -[![R-CMD-check](https://github.com/Athanasiamo/colorhex/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/Athanasiamo/colorhex/actions/workflows/R-CMD-check.yaml) +[![R-CMD-check](https://github.com/drmowinckels/colorhex/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/drmowinckels/colorhex/actions/workflows/R-CMD-check.yaml) @@ -38,8 +37,8 @@ It also has lots of user-made palettes that can be used and browsed. You can install the development version from [GitHub](https://github.com/) with: ``` r -# install.packages("devtools") -devtools::install_github("Athanasiamo/colorhex", ref = "main") +# install.packages("remotes") +remotes::install_github("drmowinckels/colorhex", ref = "main") ``` ## Example diff --git a/README.md b/README.md index d70f48e..9224533 100644 --- a/README.md +++ b/README.md @@ -7,8 +7,7 @@ [![CRAN status](https://www.r-pkg.org/badges/version/colorhex)](https://CRAN.R-project.org/package=colorhex) -[![R-CMD-check](https://github.com/Athanasiamo/colorhex/workflows/R-CMD-check/badge.svg)](https://github.com/Athanasiamo/colorhex/actions) -[![R-CMD-check](https://github.com/Athanasiamo/colorhex/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/Athanasiamo/colorhex/actions/workflows/R-CMD-check.yaml) +[![R-CMD-check](https://github.com/drmowinckels/colorhex/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/drmowinckels/colorhex/actions/workflows/R-CMD-check.yaml) The goal of colorhex is to create an interface to @@ -28,8 +27,8 @@ You can install the development version from [GitHub](https://github.com/) with: ``` r -# install.packages("devtools") -devtools::install_github("Athanasiamo/colorhex", ref = "main") +# install.packages("remotes") +remotes::install_github("drmowinckels/colorhex", ref = "main") ``` ## Example @@ -59,15 +58,15 @@ x #> [1] "#ff80ed" "#065535" "#000000" "#133337" "#ffc0cb" "#ffffff" "#ffe4e1" #> [8] "#008080" "#ff0000" "#e6e6fa" "#ffd700" "#00ffff" "#ffa500" "#0000ff" #> [15] "#ff7373" "#c6e2ff" "#40e0d0" "#b0e0e6" "#d3ffce" "#f0f8ff" "#666666" -#> [22] "#faebd7" "#bada55" "#003366" "#fa8072" "#ffb6c1" "#ffff00" "#c0c0c0" -#> [29] "#c39797" "#800080" "#800000" "#00ff00" "#7fffd4" "#eeeeee" "#cccccc" -#> [36] "#fff68f" "#f08080" "#20b2aa" "#ffc3a0" "#333333" "#66cdaa" "#c0d6e4" -#> [43] "#ff6666" "#ff00ff" "#cbbeb5" "#ffdab9" "#ff7f50" "#468499" "#afeeee" -#> [50] "#008000" "#b4eeb4" "#00ced1" "#f6546a" "#660066" "#0e2f44" "#b6fcd5" -#> [57] "#696969" "#daa520" "#f5f5f5" "#990000" "#6897bb" "#000080" "#808080" -#> [64] "#088da5" "#f5f5dc" "#8b0000" "#8a2be2" "#dddddd" "#ccff00" "#ffff66" -#> [71] "#2acaea" "#101010" "#81d8d0" "#0a75ad" "#ff4040" "#66cccc" "#420420" -#> [78] "#a0db8e" "#ff1493" "#cc0000" "#3399ff" "#999999" "#00ff7f" "#794044" +#> [22] "#faebd7" "#bada55" "#fa8072" "#003366" "#ffb6c1" "#c0c0c0" "#ffff00" +#> [29] "#800000" "#800080" "#c39797" "#00ff00" "#7fffd4" "#fff68f" "#eeeeee" +#> [36] "#cccccc" "#f08080" "#20b2aa" "#ffc3a0" "#333333" "#66cdaa" "#c0d6e4" +#> [43] "#ff6666" "#ff00ff" "#cbbeb5" "#ffdab9" "#468499" "#ff7f50" "#afeeee" +#> [50] "#b4eeb4" "#00ced1" "#008000" "#660066" "#f6546a" "#0e2f44" "#b6fcd5" +#> [57] "#990000" "#696969" "#f5f5f5" "#daa520" "#000080" "#6897bb" "#808080" +#> [64] "#f5f5dc" "#088da5" "#8b0000" "#8a2be2" "#81d8d0" "#ccff00" "#ffff66" +#> [71] "#ff4040" "#dddddd" "#2acaea" "#101010" "#0a75ad" "#ff1493" "#420420" +#> [78] "#66cccc" "#a0db8e" "#999999" "#794044" "#3399ff" "#cc0000" "#00ff7f" scales::show_col(x) ``` diff --git a/cran-comments.md b/cran-comments.md index 146e096..0ba87ef 100644 --- a/cran-comments.md +++ b/cran-comments.md @@ -1,18 +1,6 @@ -## Test environments -* local R installation, R 4.0.2 -* ubuntu 16.04 (on travis-ci), R 4.0.2 -* win-builder (devel) -* github actions: - - {os: windows-latest, r: 'release'} - - {os: macOS-latest, r: 'release'} - - {os: ubuntu-20.04, r: 'release', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"} - - {os: ubuntu-20.04, r: 'devel', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"} - - ## R CMD check results -0 errors | 0 warnings | 1 note +0 errors | 0 warnings | 0 note * This is a new release. -* added `on.exit()` before changing `par()` -* added 'https:' to url in DESCRIPTION +* Fixes example failures when server is unreachable diff --git a/man/figures/README-latest-1.png b/man/figures/README-latest-1.png index a9dee4c..c218a38 100644 Binary files a/man/figures/README-latest-1.png and b/man/figures/README-latest-1.png differ diff --git a/man/figures/README-pop-cols-1.png b/man/figures/README-pop-cols-1.png index 3c48811..cb5ce14 100644 Binary files a/man/figures/README-pop-cols-1.png and b/man/figures/README-pop-cols-1.png differ diff --git a/man/figures/README-popular-palettes-1.png b/man/figures/README-popular-palettes-1.png index f11a107..340d66b 100644 Binary files a/man/figures/README-popular-palettes-1.png and b/man/figures/README-popular-palettes-1.png differ diff --git a/man/get_color.Rd b/man/get_color.Rd index 0d0ba5a..006e173 100644 --- a/man/get_color.Rd +++ b/man/get_color.Rd @@ -17,6 +17,7 @@ Get color information from www.color-hex.com of a hex-color. } \examples{ +if(curl::has_internet()){ get_color("#470f0f") -get_color("#f2f2f2") +} } diff --git a/man/get_latest_palettes.Rd b/man/get_latest_palettes.Rd index bfaedce..5b493bd 100644 --- a/man/get_latest_palettes.Rd +++ b/man/get_latest_palettes.Rd @@ -14,5 +14,7 @@ Retrieve the most recently made palettes from www.color-hex.com } \examples{ +if(curl::has_internet()){ get_latest_palettes() } +} diff --git a/man/get_palette.Rd b/man/get_palette.Rd index 8b54a2c..ad1aef3 100644 --- a/man/get_palette.Rd +++ b/man/get_palette.Rd @@ -17,9 +17,11 @@ Get palette information from www.color-hex.com based on the palette id (can be found in the url) } \examples{ +if(curl::has_internet()){ get_palette(103107) # Lookup multiple palettes id <- c(103161, 103107) get_palette(id) } +} diff --git a/man/get_popular_colors.Rd b/man/get_popular_colors.Rd index b3883da..0fd319a 100644 --- a/man/get_popular_colors.Rd +++ b/man/get_popular_colors.Rd @@ -15,5 +15,7 @@ that have been liked by the most users. This function will retrieve all of these. } \examples{ +if(curl::has_internet()){ get_popular_colors() } +} diff --git a/man/get_popular_palettes.Rd b/man/get_popular_palettes.Rd index 9d61e64..e46a11b 100644 --- a/man/get_popular_palettes.Rd +++ b/man/get_popular_palettes.Rd @@ -10,9 +10,11 @@ get_popular_palettes() data.frame with name, id and colours } \description{ -Retrieve the palettes most users have favourited -from www.color-hex.com +Retrieve the palettes most users have +checked as favorites from www.color-hex.com } \examples{ +if(curl::has_internet()){ get_popular_palettes() } +} diff --git a/man/scale-colorhex.Rd b/man/scale-colorhex.Rd index 1e23828..ffc9fed 100644 --- a/man/scale-colorhex.Rd +++ b/man/scale-colorhex.Rd @@ -48,20 +48,21 @@ to create colour scales to be used in ggplot2. } \section{Functions}{ \itemize{ -\item \code{scale_colour_colorhex_d}: Discrete colour scale +\item \code{scale_colour_colorhex_d()}: Discrete colour scale -\item \code{scale_color_colorhex_d}: Discrete colour scale +\item \code{scale_color_colorhex_d()}: Discrete colour scale -\item \code{scale_fill_colorhex_d}: Discrete fill scale +\item \code{scale_fill_colorhex_d()}: Discrete fill scale -\item \code{scale_colour_colorhex_c}: Continuous colour scale +\item \code{scale_colour_colorhex_c()}: Continuous colour scale -\item \code{scale_color_colorhex_c}: Continuous colour scale +\item \code{scale_color_colorhex_c()}: Continuous colour scale -\item \code{scale_fill_colorhex_c}: Continuous fill scale -}} +\item \code{scale_fill_colorhex_c()}: Continuous fill scale +}} \examples{ +if(curl::has_internet()){ library(ggplot2) x <- get_color("#008080") @@ -85,4 +86,5 @@ ggplot(mtcars, aes(mpg, disp, colour = factor(cyl))) + ggplot(mtcars, aes(mpg, disp, colour = factor(cyl))) + geom_point() + scale_color_colorhex_d(x, "shades") + } } diff --git a/man/scale-palettehex.Rd b/man/scale-palettehex.Rd index d5e2c5a..ba436a1 100644 --- a/man/scale-palettehex.Rd +++ b/man/scale-palettehex.Rd @@ -47,20 +47,21 @@ can be made for the scale. } \section{Functions}{ \itemize{ -\item \code{scale_colour_palettehex_d}: Discrete colour scale +\item \code{scale_colour_palettehex_d()}: Discrete colour scale -\item \code{scale_color_palettehex_d}: Discrete colour scale +\item \code{scale_color_palettehex_d()}: Discrete colour scale -\item \code{scale_fill_palettehex_d}: Discrete fill scale +\item \code{scale_fill_palettehex_d()}: Discrete fill scale -\item \code{scale_colour_palettehex_c}: Continuous colour scale +\item \code{scale_colour_palettehex_c()}: Continuous colour scale -\item \code{scale_color_palettehex_c}: Continuous colour scale +\item \code{scale_color_palettehex_c()}: Continuous colour scale -\item \code{scale_fill_palettehex_c}: Continuous fill scale -}} +\item \code{scale_fill_palettehex_c()}: Continuous fill scale +}} \examples{ +if(curl::has_internet()){ library(ggplot2) x <- get_popular_palettes() @@ -81,3 +82,4 @@ ggplot(mtcars, aes(mpg, disp, colour = factor(cyl))) + geom_point() + scale_color_palettehex_d(x, 1872) } +}