emilhvitfeldt / paletteer Goto Github PK
View Code? Open in Web Editor NEWđ¨đ¨đ¨ Collection of most color palettes in a single R package
Home Page: https://emilhvitfeldt.github.io/paletteer/
License: Other
đ¨đ¨đ¨ Collection of most color palettes in a single R package
Home Page: https://emilhvitfeldt.github.io/paletteer/
License: Other
# setup
set.seed(123)
library(tidyverse)
library(ggplot2)
library(paletteer)
# there are some palettes with length 0
tibble::as_tibble(paletteer::palettes_d_names) %>%
dplyr::filter(package == "ggthemes") %>%
dplyr::arrange(length)
#> # A tibble: 51 x 4
#> package palette length type
#> <chr> <chr> <int> <chr>
#> 1 ggthemes few_light 0 qualitative
#> 2 ggthemes few_medium 0 qualitative
#> 3 ggthemes few_dark 0 qualitative
#> 4 ggthemes hc_default 0 qualitative
#> 5 ggthemes hc_darkunica 0 qualitative
#> 6 ggthemes solarized_base 0 sequential
#> 7 ggthemes solarized_accents 0 qualitative
#> 8 ggthemes tableau_Classic 10 1 sequential
#> 9 ggthemes tableau_Classic 10 Medium 1 sequential
#> 10 ggthemes tableau_Classic 10 Light 1 sequential
#> # ... with 41 more rows
# checking length of a palette
tibble::as_tibble(paletteer::palettes_d_names) %>%
dplyr::filter(package == "ggthemes", palette == "excel_themes")
#> # A tibble: 1 x 4
#> package palette length type
#> <chr> <chr> <int> <chr>
#> 1 ggthemes excel_themes 50 sequential
# using it
ggplot(iris, aes(Sepal.Length, Sepal.Width, color = Species)) +
geom_point() +
scale_color_paletteer_d(ggthemes, excel_themes)
#> Warning: Removed 150 rows containing missing values (geom_point).
#> Error in grDevices::col2rgb(colour, TRUE): invalid color name 'NULL'
Created on 2019-02-04 by the reprex package (v0.2.1)
devtools::session_info()
#> - Session info ----------------------------------------------------------
#> setting value
#> version R Under development (unstable) (2018-11-30 r75724)
#> os Windows 10 x64
#> system x86_64, mingw32
#> ui RTerm
#> language (EN)
#> collate English_United States.1252
#> ctype English_United States.1252
#> tz America/New_York
#> date 2019-02-04
#>
#> - Packages --------------------------------------------------------------
#> package * version date lib
#> assertthat 0.2.0 2017-04-11 [1]
#> backports 1.1.3 2018-12-14 [1]
#> broom 0.5.1.9000 2019-01-20 [1]
#> callr 3.1.1 2018-12-21 [1]
#> cellranger 1.1.0 2016-07-27 [1]
#> cli 1.0.1.9000 2019-01-20 [1]
#> colorspace 1.4-0 2019-01-13 [1]
#> crayon 1.3.4 2017-09-16 [1]
#> curl 3.3 2019-01-10 [1]
#> desc 1.2.0 2019-01-21 [1]
#> devtools 2.0.1.9000 2019-01-29 [1]
#> digest 0.6.18 2018-10-10 [1]
#> dplyr * 0.8.0 2019-01-31 [1]
#> evaluate 0.12 2018-10-09 [1]
#> fansi 0.4.0 2018-11-05 [1]
#> forcats * 0.3.0 2018-02-19 [1]
#> fs 1.2.6 2018-08-23 [1]
#> generics 0.0.2 2019-01-20 [1]
#> ggplot2 * 3.1.0.9000 2019-01-31 [1]
#> glue 1.3.0 2018-07-17 [1]
#> gtable 0.2.0 2016-02-26 [1]
#> haven 2.0.0 2018-11-22 [1]
#> highr 0.7 2018-06-09 [1]
#> hms 0.4.2 2018-03-10 [1]
#> htmltools 0.3.6 2017-04-28 [1]
#> httr 1.4.0 2018-12-11 [1]
#> jsonlite 1.6 2018-12-07 [1]
#> knitr 1.21 2018-12-10 [1]
#> labeling 0.3 2014-08-23 [1]
#> lazyeval 0.2.1 2017-10-29 [1]
#> lubridate 1.7.4 2018-04-11 [1]
#> magrittr 1.5 2014-11-22 [1]
#> memoise 1.1.0 2017-04-21 [1]
#> mime 0.6 2018-10-05 [1]
#> modelr 0.1.2 2018-05-11 [1]
#> munsell 0.5.0 2018-06-12 [1]
#> paletteer * 0.2.0 2019-02-04 [1]
#> pillar 1.3.1 2018-12-15 [1]
#> pkgbuild 1.0.2 2018-10-16 [1]
#> pkgconfig 2.0.2 2018-08-16 [1]
#> pkgload 1.0.2 2018-10-29 [1]
#> prettyunits 1.0.2 2015-07-13 [1]
#> processx 3.2.1 2018-12-05 [1]
#> ps 1.3.0 2018-12-21 [1]
#> purrr * 0.3.0 2019-01-25 [1]
#> R6 2.3.0 2018-10-04 [1]
#> Rcpp 1.0.0 2018-11-07 [1]
#> readr * 1.3.1 2018-12-21 [1]
#> readxl 1.2.0 2018-12-19 [1]
#> remotes 2.0.2 2018-10-30 [1]
#> rlang 0.3.1 2019-01-08 [1]
#> rmarkdown 1.11 2018-12-08 [1]
#> rprojroot 1.3-2 2018-01-03 [1]
#> rvest 0.3.2 2016-06-17 [1]
#> scales 1.0.0 2018-08-09 [1]
#> sessioninfo 1.1.1 2018-11-05 [1]
#> stringi 1.2.4 2018-07-20 [1]
#> stringr * 1.3.1 2018-05-10 [1]
#> testthat 2.0.1 2018-10-13 [1]
#> tibble * 2.0.1 2019-01-12 [1]
#> tidyr * 0.8.2 2018-10-28 [1]
#> tidyselect 0.2.5 2018-10-11 [1]
#> tidyverse * 1.2.1 2017-11-14 [1]
#> usethis 1.4.0.9000 2019-01-29 [1]
#> utf8 1.1.4 2018-05-24 [1]
#> withr 2.1.2 2018-03-15 [1]
#> xfun 0.4 2018-10-23 [1]
#> xml2 1.2.0 2018-01-24 [1]
#> yaml 2.2.0 2018-07-25 [1]
#> source
#> CRAN (R 3.5.1)
#> CRAN (R 3.6.0)
#> Github (tidymodels/broom@66411c4)
#> CRAN (R 3.6.0)
#> CRAN (R 3.5.1)
#> Github (r-lib/cli@94e2fc5)
#> CRAN (R 3.6.0)
#> CRAN (R 3.5.1)
#> CRAN (R 3.6.0)
#> Github (r-lib/desc@42b9578)
#> Github (r-lib/devtools@e4e57aa)
#> CRAN (R 3.5.1)
#> Github (tidyverse/dplyr@67b9f4f)
#> CRAN (R 3.5.1)
#> Github (brodieG/fansi@ab11e9c)
#> CRAN (R 3.5.1)
#> CRAN (R 3.5.1)
#> Github (r-lib/generics@d59e6b4)
#> Github (tidyverse/ggplot2@54e773b)
#> CRAN (R 3.5.1)
#> CRAN (R 3.5.1)
#> CRAN (R 3.6.0)
#> CRAN (R 3.5.1)
#> CRAN (R 3.5.1)
#> CRAN (R 3.5.1)
#> CRAN (R 3.6.0)
#> CRAN (R 3.6.0)
#> CRAN (R 3.6.0)
#> CRAN (R 3.5.0)
#> CRAN (R 3.5.1)
#> CRAN (R 3.5.1)
#> CRAN (R 3.5.1)
#> CRAN (R 3.5.1)
#> CRAN (R 3.5.1)
#> CRAN (R 3.5.1)
#> CRAN (R 3.5.1)
#> CRAN (R 3.6.0)
#> CRAN (R 3.6.0)
#> CRAN (R 3.5.1)
#> CRAN (R 3.5.1)
#> CRAN (R 3.6.0)
#> CRAN (R 3.5.1)
#> CRAN (R 3.6.0)
#> CRAN (R 3.6.0)
#> Github (tidyverse/purrr@240f7b2)
#> CRAN (R 3.5.1)
#> CRAN (R 3.6.0)
#> CRAN (R 3.6.0)
#> CRAN (R 3.6.0)
#> CRAN (R 3.6.0)
#> CRAN (R 3.6.0)
#> CRAN (R 3.6.0)
#> CRAN (R 3.5.1)
#> CRAN (R 3.5.1)
#> CRAN (R 3.5.1)
#> CRAN (R 3.6.0)
#> CRAN (R 3.6.0)
#> CRAN (R 3.5.1)
#> CRAN (R 3.5.1)
#> CRAN (R 3.6.0)
#> CRAN (R 3.6.0)
#> CRAN (R 3.5.1)
#> CRAN (R 3.5.1)
#> Github (r-lib/usethis@5a0680b)
#> CRAN (R 3.5.1)
#> CRAN (R 3.5.1)
#> CRAN (R 3.6.0)
#> CRAN (R 3.5.1)
#> CRAN (R 3.5.1)
#>
#> [1] C:/Users/inp099/Documents/R/win-library/3.6
#> [2] C:/Program Files/R/R-devel/library
Hi,
Really cool package. I appreciate what you've done here.
I'm running into a bit of trouble passing the names of packages and palettes to paletteer_d()
, however.
Here's my scenario: I wanted to create a function for your package that would allow me to visualize the colors from a specific package, palette, etc. so that i could rapidly review the palettes, and see which one might best fit my needs, without having to manually entire each name. Focusing on just the fixed width discrete palettes, I made a function:
library(tidyverse)
library(paletteer)
library(pal)
color_plot_d <- function(package, name, n){
palette <- paletteer::palettes_d_names %>%
as_data_frame %>%
dplyr::filter(package == package, palette == name)
pack <- palette$package
pal <- palette$palette
n <- palette$length
pals::pal.bands(
paletteer_d(pack, pal),
main = paste(pack, pal, sep = ": ")
)
}
However, I get this error:
Error in match.arg(package, unique(paletteer::palettes_d_names$package)) :
'arg' should be one of âawtoolsâ, âdichromatâ, âdutchmastersâ, âggsciâ, âggpomologicalâ, âggthemesâ, âghibliâ, âgrDevicesâ, âjcolorsâ, âLaCroixColoRâ, âNineteenEightyRâ, ânordâ, âochReâ, âpalettetownâ, âpalsâ, âPolychromeâ, âquickpaletteâ, ârcartocolorâ, âRColorBrewerâ, âRedmonderâ, âRSkittleBrewerâ, âwesandersonâ, âyarrrâ
It seems that this behavior is the results of the follwing two lines of code in paletteer_d()
:
package <- rlang::quo_name(rlang::enquo(package))
palette <- rlang::quo_name(rlang::enquo(palette))
It appears that I can only pass quoted or unquoted versions of the name, but not object representations of the name. I'd hoped to provide a solution to this problem, but this is a level of R I'm not yet familiar with.
Instead, my work around was to simply create a duplicate of the paletteer_d()
function, but to comment out the two lines causing me problems. However, this means that if one passes an unquoted representation of a package or palette (e.g. awtools
) then a different error occurs.
#The re-worked version of `paletteer_d()`, commenting out the problematic lines.
p_d <- function(package, palette, n, direction = 1, type = c("discrete",
"continuous")) {
if (abs(direction) != 1) {
stop("direction must be 1 or -1")
}
#package <- rlang::quo_name(rlang::enquo(package))
#palette <- rlang::quo_name(rlang::enquo(palette))
package <- match.arg(package, unique(paletteer::palettes_d_names$package))
type <- match.arg(type)
pal <- paletteer::palettes_d[[c(package, palette)]]
if (is.null(pal))
stop("Palette not found. Make sure the palette name are spelled correct.")
if (missing(n)) {
n <- length(pal)
}
if (type == "discrete" && n > length(pal)) {
stop(paste("Number of requested colors greater than this palette can offer which is ",
length(pal), ".", sep = ""))
}
out <- switch(type, continuous = (grDevices::colorRampPalette(pal))(n),
discrete = pal[1:n])
if (direction == -1) {
rev(out)
}
else {
out
}
}
#The palette generation function I made:
color_plot_d <- function(package, name){
palette <- paletteer::palettes_d_names %>%
as_data_frame %>%
dplyr::filter(package == package, palette == name)
pack <- palette$package
pal <- palette$palette
pals::pal.bands(
p_d(pack, pal),
main = paste(pack, pal, sep = ": ")
)
}
#These all work:
color_plot_d("awstools", "a_palette")
color_plot_d(paletteer::palettes_d_names$package[1],
paletteer::palettes_d_names$palette[1])
pack <- paletteer::palettes_d_names$package[1]
pal <- paletteer::palettes_d_names$pal[1]
color_plot_d(pack, pal)
#This does not work:
color_plot_d(awstools, a_palette)
Not sure if this matters to you, but just thought I'd pass the information along, in case it was useful.
Again, I appreciate your effort on this package. Keep up the great work!
I'd be happy to help with a PR here, but I couldn't figure out an easy way of seeing the palettes from each package. I ended up going with the method used in the ochRe vignette (ochRe exports a viz_palette()
) function to make a display of some of them:
But I think the way you do things with pals::pal.bands()
in the quickpalette vignette would probably be better for this package (takes up much less space!)
https://github.com/frareb/palettesForR (it's on CRAN
)
In the various palette functions, I think it would be nice to specify package + palette with ::
# Instead of:
paletteer_d("nord", "frost")
# do
paletteer_d(nord::frost)
I am encountering the following error while downloading the development version of the package:
> remotes::install_github("EmilHvitfeldt/paletteer")
Downloading GitHub repo EmilHvitfeldt/paletteer@master
These packages have more recent versions available.
Which would you like to update?
1: All
2: CRAN packages only
3: None
4: rlang (30feeacfa... -> 5d538c44c...) [GitHub]
Enter one or more numbers, or an empty line to skip updates:
3
â checking for file 'C:\Users\inp099\AppData\Local\Temp\RtmpKoyTp5\remotesae505f222dd9\EmilHvitfeldt-paletteer-0aa4591/DESCRIPTION' (436ms)
- preparing 'paletteer': (353ms)
â checking DESCRIPTION meta-information ...
- checking for LF line-endings in source and make files and shell scripts
- checking for empty or unneeded directories
- looking to see if a 'data/datalist' file should be added
- building 'paletteer_0.2.1.9000.tar.gz'
Installing package into âC:/Users/inp099/Documents/R/win-library/3.6â
(as âlibâ is unspecified)
* installing *source* package 'paletteer' ...
** using staged installation
** R
** data
*** moving datasets to lazyload DB
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
converting help for package 'paletteer'
finding HTML links ... done
ggplot2-scales-continuous html
ggplot2-scales-discrete html
paleteer-c-wrapper html
paletteer-package html
paletteer_c html
paletteer_d html
paletteer_dynamic html
palettes_c_names html
palettes_d html
palettes_d_names html
palettes_dynamic html
palettes_dynamic_names html
wrapper_c html
*** copying figures
** building package indices
** testing if installed package can be loaded from temporary location
*** arch - i386
Error in library.dynam(dynlib, pkg, lib) :
DLL 'rgl' not found: maybe not installed for this architecture?
Error: package or namespace load failed for 'paletteer':
.onLoad failed in loadNamespace() for 'rgl', details:
call: NULL
error: Loading rgl's DLL failed.
Error: loading failed
Execution halted
*** arch - x64
ERROR: loading failed for 'i386'
* removing 'C:/Users/inp099/Documents/R/win-library/3.6/paletteer'
* restoring previous 'C:/Users/inp099/Documents/R/win-library/3.6/paletteer'
Error: Failed to install 'paletteer' from GitHub:
(converted from warning) installation of package âC:/Users/inp099/AppData/Local/Temp/RtmpKoyTp5/fileae501d8c6f5f/paletteer_0.2.1.9000.tar.gzâ had non-zero exit status
Any ideas why this might be happening?
Here is my system config, if that's of some use:
- Session info ----------------------------------------------------------------------------------------------------------------
setting value
version R version 3.6.1 (2019-07-05)
os Windows 10 x64
system x86_64, mingw32
ui RStudio
language (EN)
collate English_United States.1252
ctype English_United States.1252
tz Europe/Berlin
date 2019-10-25
- Packages --------------------------------------------------------------------------------------------------------------------
! package * version date lib source
assertthat 0.2.1 2019-03-21 [1] CRAN (R 3.6.0)
backports 1.1.5 2019-10-02 [1] CRAN (R 3.6.1)
base * 3.6.1 2019-07-05 [?] local
bit 1.1-14 2018-05-29 [1] CRAN (R 3.5.0)
bit64 0.9-7 2017-05-08 [1] CRAN (R 3.5.0)
blob 1.2.0 2019-07-09 [1] CRAN (R 3.6.1)
callr 3.3.2 2019-09-22 [1] CRAN (R 3.6.1)
cli 1.1.0 2019-03-19 [1] CRAN (R 3.6.0)
P compiler 3.6.1 2019-07-05 [2] local
crancache 0.0.0.9001 2019-05-19 [1] Github (r-lib/crancache@936fa23)
cranlike 1.0.2 2018-11-26 [1] CRAN (R 3.6.0)
crayon 1.3.4 2017-09-16 [1] CRAN (R 3.5.1)
curl 4.2 2019-09-24 [1] CRAN (R 3.6.1)
P datasets * 3.6.1 2019-07-05 [2] local
DBI 1.0.0 2018-05-02 [1] CRAN (R 3.5.1)
debugme 1.1.0.9001 2019-01-19 [1] Github (r-lib/debugme@3c3c76d)
desc 1.2.0 2019-04-03 [1] Github (r-lib/desc@c860e7b)
digest 0.6.22 2019-10-21 [1] CRAN (R 3.6.1)
P graphics * 3.6.1 2019-07-05 [2] local
P grDevices * 3.6.1 2019-07-05 [2] local
magrittr 1.5 2014-11-22 [1] CRAN (R 3.5.1)
memoise 1.1.0 2017-04-21 [1] CRAN (R 3.6.0)
P methods * 3.6.1 2019-07-05 [2] local
packrat 0.5.0 2018-11-14 [1] CRAN (R 3.6.0)
paletteer * 0.2.1.9000 2019-03-25 [1] Github (EmilHvitfeldt/paletteer@38cdb34)
parsedate 1.2.0 2019-05-08 [1] CRAN (R 3.6.0)
pillar 1.4.2 2019-06-29 [1] CRAN (R 3.6.0)
pkgbuild 1.0.6 2019-10-09 [1] CRAN (R 3.6.1)
pkgconfig 2.0.3 2019-09-22 [1] CRAN (R 3.6.1)
prettyunits 1.0.2 2015-07-13 [1] CRAN (R 3.5.1)
processx 3.4.1 2019-07-18 [1] CRAN (R 3.6.1)
ps 1.3.0 2018-12-21 [1] CRAN (R 3.6.0)
R6 2.4.0 2019-02-14 [1] CRAN (R 3.6.0)
rappdirs 0.3.1 2016-03-28 [1] CRAN (R 3.5.1)
Rcpp 1.0.2 2019-07-25 [1] CRAN (R 3.6.1)
rematch2 2.1.0 2019-07-11 [1] CRAN (R 3.6.1)
remotes 2.1.0 2019-06-24 [1] CRAN (R 3.6.0)
rlang 0.4.1 2019-10-24 [1] Github (r-lib/rlang@30feeac)
rprojroot 1.3-2 2018-01-03 [1] CRAN (R 3.5.1)
RSQLite 2.1.2 2019-07-24 [1] CRAN (R 3.6.1)
rstudioapi 0.10 2019-03-19 [1] CRAN (R 3.6.0)
sessioninfo 1.1.1 2018-11-05 [1] CRAN (R 3.6.0)
P stats * 3.6.1 2019-07-05 [2] local
tibble 2.1.3 2019-06-06 [1] CRAN (R 3.6.0)
P tools 3.6.1 2019-07-05 [2] local
P utils * 3.6.1 2019-07-05 [2] local
vctrs 0.2.0 2019-07-05 [1] CRAN (R 3.6.1)
withr 2.1.2 2018-03-15 [1] CRAN (R 3.5.1)
zeallot 0.1.0 2018-01-28 [1] CRAN (R 3.5.1)
[1] C:/Users/inp099/Documents/R/win-library/3.6
[2] C:/Program Files/R/R-3.6.1/library
P -- Loaded and on-disk path mismatch.
Look for palettes in ggthemr
https://github.com/cttobin/ggthemr
Documentation states
#' @param n Number of colors desired. If omitted, returns complete palette.
however when run returns
Error in gen_fun(name = palette[2], n = n) :
argument "n" is missing, with no default
Tests expect n to error if n is unspecified
Hi there! Thanks for writing paletteer
, I am currently using it (and prismatic
!) in
palap
, and I think itâs great, as
it provides an interface to ALL the palettes that I want!
However, recently, I have found that there is an unanticipated
snag I have run into when it comes to using it programmatically, and this
comes from itâs use of bare symbols. I was wondering if you would consider
dropping the behaviour of using bare symbols, instead using characters?
Take this example:
library(paletteer)
paletteer_c(n = 4,
package = "scico",
palette = "tofino")
#> [1] "#DED8FF" "#263B65" "#244C27" "#DAE59A"
and then, letâs say that you want to store a few colour palettes, so you
pass them in as objects. This errors, and the error message initially made me
think that perhaps I had a typo.
pkg <- "scico"
pals <- c("tofino", "davos", "lapaz")
paletteer_c(n = 4,
package = pkg,
palette = pals[1])
#> Error in match.arg(package, names(wrapper_c)): 'arg' should be one of
"gameofthrones", "ggthemes", "grDevices", "harrypotter", "oompaBase", "palr",
"pals", "scico", "viridis"
# But, instead, the workaround in this instance, is this:
library(rlang)
paletteer_c(n = 4,
package = !!sym(pkg),
palette = !!sym(pals[1]))
#> [1] "#DED8FF" "#263B65" "#244C27" "#DAE59A"
Which requires understanding a bit more about NSE - not something I would
have predicted, and something that someone new to programming might not
understand, since the error above makes them think that perhaps there
was a spelling mistake, but rather it is a problem to do with passing symbols
This behaviour gets passed onto the user of other packages - say for example
when I used palap
, and if the user wants to write their own function
wrapping palap
, they have to deal with the same challenge. For example:
library(palap) # remotes::install_github("njtierney/palap")
palap(n = 8,
palette = "GnBu",
package = "RColorBrewer")
#> [1] "#F7FCF0" "#C1E6BD" "#5CBCD1" "#0767AC" "#0767AC" "#5CBCD1" "#C1E6BD"
#> [8] "#F7FCF0"
# if you want to wrap this in a function
new_palap <- function(n, palette, package){
palap(n = n,
palette = palette,
package = package)
}
new_palap(n = 6,
palette = "GnBu",
package = "RColorBrewer")
#> Error in match.arg(package, unique(paletteer::palettes_d_names$package)): 'arg' should be one of "awtools", "dichromat", "dutchmasters", "ggsci",
"ggpomological", "ggthemes", "ghibli", "grDevices", "jcolors",
"LaCroixColoR", "NineteenEightyR", "nord", "ochRe", "palettetown", "pals",
"Polychrome", "quickpalette", "rcartocolor", "RColorBrewer", "Redmonder",
"RSkittleBrewer", "tidyquant", "wesanderson", "yarrr"
Then they canât do that - theyâll need to understand some of the features
of NSE.Overall, I think that NSE is a great feature of R, but in this instance, I
actually think it makes it harder to reason and deal with. I spent a bit of
time thinking about this, and I think that maybe it comes down this idea:
Bare symbols should be used to reference something that already exists, or
will exist, and not to denote options (except for boolean TRUE/FALSE)
select(data, barevar)
,mutate(data, newvar = barevar + 1)
In any case, what do you think about changing the API to only use
character strings? I understand that this creates breaking changes, and so might not really be desirable. But this package provides a great interface to so many colour palettes, and I think having them work as character only would mean that it will be easier to program with. I'd be happy to help with a PR to help address this if you like?
Thanks again for creating this package!
Created on 2019-10-15 by the reprex package (v0.3.0)
The CRAN
version of paletteer
is 0.2.0
, while, confusingly, the development version is 0.1.0.9000
.
It will be better if you can bump this to 0.2.0.9000
. Otherwise I - and any other developer - can't download the development version and run the package tests since the packages will depend on 0.2.0
or above.
Hey I want to package a few (discrete) colour palettes, and I was wondering if you could provide documentation for generating palette-packages that are easy to integrate with palletteer, maybe as a vignette?
Maybe this will be worth adding to the next release?
https://github.com/aljrico/harrypotter
Thanks.
I'm not exactly sure what you're trying to do here:
objs <- mget(ls("package:paletteer"), inherits = TRUE)
gen_fun <- get(paste0("paletteer_c_", package), objs)
But I'm pretty sure generating the list of objects first is unnecessary.
Also, I'd suggest using exists()
to verify if the palette wrapper is not found so that you can generate a nicer error message.
Hi.
Love this package so much! I'm trying to implement a call to it in one of my own packages, but am having a bit of a struggle.
Basically, I'm trying to let the user only specify what palette they want to use, find which package it is from, and then call paletteer to output the colours in that palette.
I'm storing the name of the package in an object called pkg
, and the palette name in palette
.
But when I try to supply these to paletteer, it wont recognise them.
I'm guessing this comes from the symbol coding somewhere, but I am unsure how to work around it.
I've made a list that had all the paletteer's in it, for convenience later:
pals = data.frame(type=c("continuous", "dynamic", "discrete"), stringsAsFactors = F)
pals$palettes = NA
pp = list(paletteer::palettes_c_names,
paletteer::palettes_dynamic_names %>% rename(palette=name),
paletteer::palettes_d_names)
for(i in 1:nrow(pals)){
pals$palettes[[i]] = as.data.frame(pp[i])
}
pals = as_tibble(pals)
The function that finds the supplied palette and its package:
scale3d = function(palette){
pal_src = paste0("^", palette, "$")
# Find index for palette match
idx = map(pals$palettes, function(x) grep(pal_src, x$palette))
# Find index for type match, for call to switch
type_indx = which(unlist(lapply(idx, function(x) !is_empty(x))))
idx = unlist(idx)
pkg = pals$palettes[[type_indx]][idx,"package"]
print(pkg)
switch(pals$type[type_indx],
"discrete" = {
paletteer::paletteer_d(package = pkg,
palette = palette)
},
"dynamic" = {
paletteer::paletteer_dynamic(package = pkg,
palette = palette)
},
"continuous" = {
paletteer::paletteer_c(package = pkg,
palette = palette)
}
)
}
Testing the function
scale3d("RdBu")
[1] "RColorBrewer"
Error in match.arg(package, unique(paletteer::palettes_d_names$package)) :
'arg' should be one of âawtoolsâ, âdichromatâ, âdutchmastersâ, âggsciâ, âggpomologicalâ, âggthemesâ, âghibliâ, âgrDevicesâ, âjcolorsâ, âLaCroixColoRâ, âNineteenEightyRâ, ânordâ, âochReâ, âpalettetownâ, âpalsâ, âPolychromeâ, âquickpaletteâ, ârcartocolorâ, âRColorBrewerâ, âRedmonderâ, âRSkittleBrewerâ, âwesandersonâ, âyarrrâ
Hi,
I'm wondering if this package may not be included because of the resulting palette redundancy for paletteer
, since colorspace
borrows palettes from other packages. Or is colorspace
worth including? I'm wondering if the focus is more about the palettes or about the collections/packages?
For example, users of paletteer
who might be more familiar with colorspace
than with other packages might locate a particular palette they are looking for more easily with colorspace
in the collection.
If there is interest, I could submit a pull request for the addition.
hcl.pals()
don't document palette argument
I think it's generally bad practice to have an argument that controls whether or not a variable is automatically quoted â and it's definitely not in keeping with tidy evaluation. I'd suggest either eliminating it (and relying on people using !!
) or using deparse(substitute(package))
to make it clear that you're not actually using tidyeval.
(If you do want to continue using tidyeval, I'd recommend using ensym()
rather than enquo()
, since you only want to capture a name, not anything more complex)
Error in paletteer_c(package = !!package, palette = !!palette, direction = direction, :
direction must be 1 or -1
Hey, thanks for this amazing package! I am importing this package functions in my package. But ever since I added paletteer
as a dependency, my Trvis CI
build is failing on both Mac OS and Linux (https://travis-ci.org/IndrajeetPatil/ggstatsplot) with the error-
ERROR: dependency âoompaBaseâ is not available for package âpaletteerâ
I checked the CRAN
results for the oompaBase
package and everything looks good (https://cran.r-project.org/web/checks/check_results_oompaBase.html), and plus the Travis CI
build seems to succeed also for paletteer
(https://travis-ci.org/EmilHvitfeldt/paletteer).
So I am wondering if you have any thoughts about why the build might be failing only for ggstatsplot
? I wonder if I've misspecified something.
would be indicators such as, monochromatic, colorblind resistant, divergent, rainbow, etc etc.
It's on CRAN as well
https://github.com/KKPMW/basetheme
citation("paletteer")
refers to an AUTHORS file, but I cannot find it. How else can I cite this package?
Hi @EmilHvitfeldt,
I'm the creator of the tidyquant
package. I have a theme_tq()
, palette_light()
, palette_green()
, palette_dark()
, scale_color_tq()
, and scale_fill_tq()
within the tidyquant package. Would you want to include any of the palettes and/or themes in paletteer
?
Here's the link to the tidyquant package: https://github.com/business-science/tidyquant
Thanks, Matt
I was thinking it would be kind of neat to have an option in which colors were assigned from the middle of a palette, rather than from the left (i.e., direction = 1) or right (i.e., direction = -1).
For example say we wanted to use the following palette, but we only had three colors:
paletteer_d(ggthemes, hc_bg)
[1] "#d5e4eb" "#c3d6df" "#ed111a" "#ebebeb" "#c9c9c9"
Normally we'd do something like:
paletteer_d(ggthemes, hc_bg, n = 3) #or possibly paletteer_d(ggthemes, hc_bg, n = 3, direction = -1)
[1] "#d5e4eb" "#c3d6df" "#ed111a"
But what if we wanted to use the middle three colors? Usually I'd do something like:
paletteer_d(ggthemes, hc_bg)[c(2:4)]
[1] "#c3d6df" "#ed111a" "#ebebeb"
That's not terrible, but it can be inconvenient if dealing with a lot of changing group conditions.
What about an even number of groups? Could include an argument for starting from the left or the right of the middle color. Maybe even one for dropping the middle color. This could include similar logic for an even number of colors and an odd number of groups.
Thus, I could see a modification of the paletteer_*
functions to include some new arguments:
paletteer_d(..., centered = c(TRUE, FALSE), side = c("left", "right", "middle"))
#Examples of functionality:
paletteer_d(ggthemes, hc_bg, n = 3, centered = TRUE) #original color index: [2, 3, 4]
[1] "#c3d6df" "#ed111a" "#ebebeb"
paletteer_d(ggthemes, hc_bg, n = 4, centered = TRUE, side = "left") #original color index: [1, 2, 3, 4]
[1] "#d5e4eb" "#c3d6df" "#ed111a" "#ebebeb"
paletteer_d(ggthemes, hc_bg, n = 4, centered = TRUE, side = "right") #original color index: [2, 3, 4, 5]
[1] "#c3d6df" "#ed111a" "#ebebeb" "#c9c9c9"
paletteer_d(ggthemes, hc_bg, n = 4, centered = TRUE, side = "middle") #original color index: [1, 2, 4, 5]
[1] "#d5e4eb" "#c3d6df" "#ebebeb" "#c9c9c9"
Thoughts?
scale_color_paletteer_c(scico, berlin, 20)+
Error in paletteer_c(package = !!package, palette = !!palette, direction = direction, :
direction must be 1 or -1
I want 20 different colors that are distinct and pretty, how can I choose them ?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
đ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. đđđ
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google â¤ď¸ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.