README.md

paleval

CRAN
status Lifecycle:
experimental Travis build
status Codecov test
coverage

The goal of paleval is to help you evaluate the effectiveness of color palettes and color maps. It builds from the colorspace package, used to design color maps, and the farver package, used to evaluate the perceptual difference between two colors.

This will have to go into a design-document eventually, but for now, I’ll “puke” this here.

For the purpose of this package, following colorRamp and ggplot2 usage, we define some classes:

These follow the palette argument for ggplot2::continuous_scale() and ggplot2::discrete_scale(), as well as graphics::colorRamp() and graphics::colorRampPalette(), respectively.

I’m suspect I’m doing things in a way that the authors of colorspace, ggplot2, farver, and graphics might prefer not to consider while eating. As much as anything, this package is an attempt to reationalize and harmonize all of these concepts to myself.

There are ways to create continuous-palette functions:

There are ways to create discrete-palette functions:

Other functions:

Here’s a reference on delta E - can we find something more definitive?

Installation

You can install the development version of paleval from GitHub with:

devtools::install_github("ijlyttle/paleval")

Example

library("paleval")

fcont <- pev_fcont("Dynamic") # continuous palette-function, from colorspace
fdisc <- pev_fdisc(fcont, method = "panel") # discrete palette-function

data_sep <- pev_data_separation(fdisc(7))
print(data_sep)
#> # A tibble: 196 x 5
#>    cvd       i hex     hex_ref distance
#>    <chr> <int> <chr>   <chr>      <dbl>
#>  1 none      1 #E396A0 #E396A0      0  
#>  2 none      1 #E396A0 #D796D0     14.9
#>  3 none      1 #E396A0 #9FA8E2     26.4
#>  4 none      1 #E396A0 #4CB9CC     53.6
#>  5 none      1 #E396A0 #50BE9B     53.0
#>  6 none      1 #E396A0 #97B56C     45.3
#>  7 none      1 #E396A0 #CBA56E     27.1
#>  8 none      2 #D796D0 #E396A0     14.9
#>  9 none      2 #D796D0 #D796D0      0  
#> 10 none      2 #D796D0 #9FA8E2     18.3
#> # … with 186 more rows

pev_gg_separation(data_sep)

data_drv <- pev_data_derivative("Purple-Green")
data_drv
#> # A tibble: 164 x 4
#>    cvd       x hex     d_distance_d_x
#>    <chr> <dbl> <chr>            <dbl>
#>  1 none  0     #492050           136.
#>  2 none  0.025 #562A5E           152.
#>  3 none  0.05  #65346D           162.
#>  4 none  0.075 #733F7C           169.
#>  5 none  0.1   #82498C           172.
#>  6 none  0.125 #90529C           178.
#>  7 none  0.15  #9F5CAB           187.
#>  8 none  0.175 #AE65BB           170.
#>  9 none  0.2   #B574C2           167.
#> 10 none  0.225 #BD82C9           158.
#> # … with 154 more rows

pev_gg_derivative(data_drv)

data_dist <- pev_data_distance("Purple-Green")
data_dist
#> # A tibble: 164 x 5
#>    cvd       x hex     hex_ref distance
#>    <chr> <dbl> <chr>   <chr>      <dbl>
#>  1 none  0     #492050 #492050     0   
#>  2 none  0.025 #562A5E #492050     3.59
#>  3 none  0.05  #65346D #492050     7.58
#>  4 none  0.075 #733F7C #492050    11.7 
#>  5 none  0.1   #82498C #492050    16.0 
#>  6 none  0.125 #90529C #492050    20.1 
#>  7 none  0.15  #9F5CAB #492050    24.7 
#>  8 none  0.175 #AE65BB #492050    29.2 
#>  9 none  0.2   #B574C2 #492050    33.5 
#> 10 none  0.225 #BD82C9 #492050    38.1 
#> # … with 154 more rows

pev_gg_distance(data_dist)

data_hcl <- pev_data_hcl("Viridis", n = 41)
data_hcl
#> # A tibble: 164 x 7
#>    cvd       x hex       hue chroma luminance is_rgb_limit
#>    <chr> <dbl> <chr>   <dbl>  <dbl>     <dbl> <lgl>       
#>  1 none  0     #FDE333  74.8   94.9      89.9 FALSE       
#>  2 none  0.025 #EFE32D  80.8   93.6      88.7 FALSE       
#>  3 none  0.05  #E1E22B  86.3   92.4      87.3 FALSE       
#>  4 none  0.075 #D2E02E  91.7   90.8      85.6 FALSE       
#>  5 none  0.1   #C2DE34  97.5   89.4      83.9 FALSE       
#>  6 none  0.125 #B2DC3C 103.    88.2      82.4 FALSE       
#>  7 none  0.15  #A2D945 109.    86.5      80.6 FALSE       
#>  8 none  0.175 #90D74E 115.    85.7      79.1 FALSE       
#>  9 none  0.2   #7ED357 120.    83.6      77.1 FALSE       
#> 10 none  0.225 #6AD05F 126.    82.6      75.5 FALSE       
#> # … with 154 more rows

data_hcl_ref <- pev_data_hcl_ref("Viridis", pev_fcont("Viridis")(0.55))

pev_gg_hcl_bloom(data_hcl, data_hcl_ref)

pev_data_hcl("Dynamic", n = 12) %>% pev_gg_hcl_bloom()

pev_gg_hcl_plane(data_hcl, data_hcl_ref)

pev_gg_hcl_spectrum(data_hcl, data_hcl_ref)

Code of Conduct

Please note that the ‘paleval’ project is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.



ijlyttle/paleval documentation built on Dec. 25, 2019, 9:17 a.m.