-
Notifications
You must be signed in to change notification settings - Fork 46
/
README.Rmd
159 lines (114 loc) · 5.84 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r setup, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-"
)
```
# paletteer <img src='man/figures/logo.png' style="float:right" height="139" />
<!-- badges: start -->
[![R-CMD-check](https://github.com/emilhvitfeldt/paletteer/workflows/R-CMD-check/badge.svg)](https://github.com/emilhvitfeldt/paletteer/actions)
[![CRAN status](https://www.r-pkg.org/badges/version/paletteer)](https://cran.r-project.org/package=paletteer)
[![CRAN_Download_Badge](http://cranlogs.r-pkg.org/badges/paletteer)](https://CRAN.R-project.org/package=paletteer)
[![Codecov test coverage](https://codecov.io/gh/emilhvitfeldt/paletteer/branch/main/graph/badge.svg)](https://app.codecov.io/gh/emilhvitfeldt/paletteer?branch=main)
[![Lifecycle: stable](https://img.shields.io/badge/lifecycle-stable-brightgreen.svg)](https://lifecycle.r-lib.org/articles/stages.html)
<!-- badges: end -->
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](https://CRAN.R-project.org) with:
``` r
install.packages("paletteer")
```
If you want the development version instead then install directly from GitHub:
```{r, eval=FALSE}
# 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:
```{r echo=FALSE}
library(paletteer)
pals::pal.bands(
paletteer_d("nord::frost"),
paletteer_d("dutchmasters::milkmaid"),
paletteer_d("LaCroixColoR::Lime"),
main = "Fixed width palettes",
labels = c("nord\n frost", "dutchmasters\n milkmaid", "LaCroixColoR\n Lime")
)
```
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:
```{r echo=FALSE}
pals::pal.bands(
paletteer_dynamic("cartography::green.pal", 2),
paletteer_dynamic("cartography::green.pal", 5),
paletteer_dynamic("cartography::green.pal", 8),
main = "Dynamic palettes",
labels = c("cartography\n green.pal\n n = 2",
"cartography\n green.pal\n n = 5",
"cartography\n green.pal\n n = 6")
)
```
Lastly we have the continuous palettes which provides as many colors as you need for a smooth transition of color:
```{r echo=FALSE}
library(paletteer)
pals::pal.bands(
paletteer_c("viridis::inferno", 256),
paletteer_c("grDevices::terrain.colors", 256),
paletteer_c("scico::berlin", 256),
main = "continuous palettes",
labels = c("viridis\n inferno", "grDevices\n terrain.colors", "scico\n berlin")
)
```
This package includes `r nrow(palettes_c_names) + nrow(palettes_d_names) + nrow(palettes_dynamic_names)` palettes from `r length(unique(c(palettes_c_names$package, palettes_d_names$package, palettes_dynamic_names$package))) - 2` 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](https://github.com/EmilHvitfeldt/r-color-palettes) 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.
```{r}
paletteer_c("scico::berlin", n = 10)
paletteer_d("nord::frost")
paletteer_dynamic("cartography::green.pal", 5)
```
All of the functions now also support tab completion to easily access the hundreds of choices
![](man/figures/paletteer-demo.gif)
## ggplot2 scales
Lastly the package also includes scales for `ggplot2` using the same standard interface
```{r}
library(ggplot2)
ggplot(iris, aes(Sepal.Length, Sepal.Width, color = Species)) +
geom_point() +
scale_color_paletteer_d("nord::aurora")
```
## Palette explorer
A [web application](https://r-graph-gallery.com/color-palette-finder) is available to quickly explore the available palettes.
[![](man/figures/colorPaletteFinder.gif)](https://r-graph-gallery.com/color-palette-finder)
## Breaking changes
In version <= 0.2.1 a palatte was selected by specifying a `package` and `palette` argument like so
```{r, eval=FALSE}
paletteer_c(package = "nord", palette = "frost")
```
After version 0.2.1 palettes are selected using the syntax `"packagename::palettename"` inside the palette functions.
```{r, eval=FALSE}
paletteer_c("nord::frost")
```
## Special thanks
- [Hadley Wickham](https://github.com/hadley) For helpful code improvements.
## Included packages
**paletteer** includes palettes from the following packages:
```{r, echo=FALSE}
p_df <- paletteer_packages
p_df$Github <- ifelse(!is.na(paletteer_packages$Github),
paste0("[", paletteer_packages$Github, " - ",
paletteer_packages$github_ver, "](https://github.com/",
paletteer_packages$Github, ")"),
"-")
p_df$CRAN <- ifelse(paletteer_packages$CRAN,
paste0("[", paletteer_packages$CRAN_ver, "](https://CRAN.R-project.org/package=", paletteer_packages$Name,
")"),
"-")
p_df$CRAN[p_df$Name == "grDevices"] <- p_df$CRAN_ver[p_df$Name == "grDevices"]
knitr::kable(p_df[c("Name", "Github", "CRAN")])
```