GithubHelp home page GithubHelp logo

emilhvitfeldt / paletteer Goto Github PK

View Code? Open in Web Editor NEW
843.0 18.0 45.0 16.72 MB

🎨🎨🎨 Collection of most color palettes in a single R package

Home Page: https://emilhvitfeldt.github.io/paletteer/

License: Other

R 100.00%
rstats r color-palette palettes

paletteer's Introduction

paletteer

R-CMD-check CRAN status CRAN_Download_Badge Codecov test coverage Lifecycle: stable

The goal of paletteer is to be a comprehensive collection of color palettes in R using a common interface. Think of it as the “caret of palettes”.

Notice This version is not backwards compatible with versions <= 0.2.1. Please refer to the end of the readme for breaking changes

Installation

You can install the released version of paletteer from CRAN with:

install.packages("paletteer")

If you want the development version instead then install directly from GitHub:

# install.packages("devtools")
devtools::install_github("EmilHvitfeldt/paletteer")

Palettes

The palettes are divided into 2 groups; discrete and continuous. For discrete palette you have the choice between the fixed width palettes and dynamic palettes. Most common of the two are the fixed width palettes which have a set amount of colors which doesn’t change when the number of colors requested vary like the following palettes:

on the other hand we have the dynamic palettes where the colors of the palette depend on the number of colors you need like the green.pal palette from the cartography package:

Lastly we have the continuous palettes which provides as many colors as you need for a smooth transition of color:

This package includes 2759 palettes from 75 different packages and information about these can be found in the following data.frames: palettes_c_names, palettes_d_names and palettes_dynamic_names. Additionally this github repo showcases all the palettes included in the package and more.

Examples

All the palettes can be accessed from the 3 functions paletteer_c(), paletteer_d() and paletteer_dynamic() using the by using the syntax packagename::palettename.

paletteer_c("scico::berlin", n = 10)
#> <colors>
#> #9EB0FFFF #5AA3DAFF #2D7597FF #194155FF #11181DFF #270C01FF #501802FF #8A3F2AFF #C37469FF #FFACACFF
paletteer_d("nord::frost")
#> <colors>
#> #8FBCBBFF #88C0D0FF #81A1C1FF #5E81ACFF
paletteer_dynamic("cartography::green.pal", 5)
#> <colors>
#> #B8D9A9FF #8DBC80FF #5D9D52FF #287A22FF #17692CFF

All of the functions now also support tab completion to easily access the hundreds of choices

ggplot2 scales

Lastly the package also includes scales for ggplot2 using the same standard interface

library(ggplot2)

ggplot(iris, aes(Sepal.Length, Sepal.Width, color = Species)) +
  geom_point() +
  scale_color_paletteer_d("nord::aurora")

Breaking changes

In version <= 0.2.1 a palatte was selected by specifying a package and palette argument like so

paletteer_c(package = "nord", palette = "frost")

After version 0.2.1 palettes are selected using the syntax "packagename::palettename" inside the palette functions.

paletteer_c("nord::frost")

Special thanks

Included packages

paletteer includes palettes from the following packages:

Name Github CRAN
ButterflyColors junqueiragaabi/ButterflyColors - 0.0.0.9000 -
DresdenColor katiesaund/DresdenColor - 0.0.0.9000 -
IslamicArt lambdamoses/IslamicArt - 0.1.0 -
LaCroixColoR johannesbjork/LaCroixColoR - 0.1.0 -
Manu G-Thomson/Manu - 0.0.2 -
MapPalettes disarm-platform/MapPalettes - 0.0.2 -
MetBrewer BlakeRMills/MetBrewer - 0.3.0 0.2.0
MexBrewer paezha/MexBrewer - 0.0.2 -
MoMAColors BlakeRMills/MoMAColors - 0.0.0.9000 -
NatParksPalettes kevinsblake/NatParksPalettes - 0.2.0 0.2.0
NineteenEightyR m-clark/NineteenEightyR - 0.1.0 -
PNWColors jakelawlor/PNWColors - 0.1.0 -
Polychrome - 1.5.1
PrettyCols nrennie/PrettyCols - 1.0.1.9001 1.0.1
RColorBrewer - 1.1.3
RSkittleBrewer alyssafrazee/RSkittleBrewer - 1.1 -
Redmonder - 0.2.0
awtools awhstin/awtools - 0.2.1 -
basetheme karoliskoncevicius/basetheme - 0.1.3 0.1.3
beyonce dill/beyonce - 0.1 -
calecopal an-bui/calecopal - 0.1.0 -
cartography riatelab/cartography - 3.1.5 3.1.4
colRoz jacintak/colRoz - 0.2.2 -
colorBlindness - 0.1.9
colorblindr clauswilke/colorblindr - 0.1.0 -
dichromat - 2.0-0.1
dutchmasters EdwinTh/dutchmasters - 0.1.0 -
feathers shandiya/feathers - 0.0.0.9000 -
fishualize nschiett/fishualize - 0.2.3 0.2.3
futurevisions JoeyStanley/futurevisions - 0.1.1 -
ggpomological gadenbuie/ggpomological - 0.1.2 -
ggprism csdaw/ggprism - 1.0.3.9000 1.0.4
ggsci nanxstats/ggsci - 3.0.0 3.0.0
ggthemes jrnold/ggthemes - 4.2.4 5.0.0
ggthemr Mikata-Project/ggthemr - 1.1.0 -
ghibli ewenme/ghibli - 0.3.3.9000 0.3.3
grDevices - 4.3.1
harrypotter aljrico/harrypotter - 2.1.1 2.1.1
impressionist.colors - 1.0
jcolors jaredhuling/jcolors - 0.0.5 -
khroma tesselle/khroma - 1.12.0.9000 1.12.0
lisa tylerlittlefield/lisa - 0.1.2.9000 0.1.2
ltc loukesio/ltc_palettes - 0.2.0 -
miscpalettes EmilHvitfeldt/miscpalettes - 0.0.0.9000 -
musculusColors dawnbarlow/musculusColors - 0.1.0 -
nationalparkcolors katiejolly/nationalparkcolors - 0.1.0 -
nbapalettes murrayjw/nbapalettes - 0.1.0.9000 0.1.0
nord jkaupp/nord - 1.0.0 1.0.0
ochRe hollylkirk/ochRe - 1.0.0 -
oompaBase - 3.2.9
palettesForR frareb/palettesForR - 0.1.2 0.1.2
palettetown timcdlucas/palettetown - 0.1.1.90000 0.1.1
palr AustralianAntarcticDivision/palr - 0.4.0 0.4.0
pals kwstat/pals - 1.9 1.8
peRReo jbgb13/peRReo - 0.1.0 -
popthemes johnmackintosh/popthemes - 0.0.0.9000 -
rcartocolor Nowosad/rcartocolor - 2.1.1 2.1.1
rockthemes johnmackintosh/rockthemes - 0.0.0.9000 -
rtist tomasokal/rtist - 1.0.0 1.0.0
scico thomasp85/scico - 1.5.0.9000 1.5.0
severance ivelasq/severance - 0.0.0.9000 -
soilpalettes kaizadp/soilpalettes - 0.1.0 -
suffrager alburezg/suffrager - 0.1.0 -
tayloRswift asteves/tayloRswift - 0.1.0 -
tidyquant business-science/tidyquant - 1.0.7.9000 1.0.7
trekcolors leonawicz/trekcolors - 0.1.3 0.1.3
tvthemes Ryo-N7/tvthemes - 1.3.2 1.3.2
unikn hneth/unikn - 0.9.0.9008 0.9.0
vangogh cherylisabella/vangogh - 0.1.1 0.1.1
vapeplot seasmith/vapeplot - 0.1.0 -
vapoRwave moldach/vapoRwave - 0.3.0 -
viridis sjmgarnier/viridis - 0.6.4 0.6.4
visibly m-clark/visibly - 0.2.9 -
waRhol alexskeels/waRhol - 0.1.0 -
werpals sciencificity/werpals - 0.1.0 -
wesanderson karthik/wesanderson - 0.3.7 0.3.7
yarrr ndphillips/yarrr - 0.1.6 NA

paletteer's People

Contributors

csaybar avatar emilhvitfeldt avatar etiennebacher avatar indrajeetpatil avatar kant avatar moldach avatar olivroy avatar teunbrand avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

paletteer's Issues

bump the development version to `0.2.0.9000`

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.

Feature request: centered palettes

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?

Add palette swatches?

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!)

How to cite paletteer?

citation("paletteer") refers to an AUTHORS file, but I cannot find it. How else can I cite this package?

Incorrect use of get()

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.

API documentation for paletteer compatible palettes?

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?

Add colorspace palettes?

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.

tidyquant theme

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

problems downloading `paletteer`

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.

Can't pass object representations of package (or pallete?) names to paletteer_d()

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!

paletteer_c argument n

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

Specify palette using :: ?

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)

scale 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)

Feature Request: Remove NSE options for package and palette.

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)

  • For example, an existing column in select(data, barevar),
  • Or a new column, such as in 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)

supplying arguments through objects not working

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” 

ggthemes palettes with no colors and some not working

# 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)

Session info
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

Travis build failing after adding paletteer as a dependency

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.