-
Notifications
You must be signed in to change notification settings - Fork 1
/
README.Rmd
122 lines (89 loc) · 4.04 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
---
output: github_document
always_allow_html: true
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE, cache = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%",
cache = FALSE,
asciicast_theme = "pkgdown"
)
asciicast::init_knitr_engine(
startup = quote({
library(tibble)
library(palettes)
set.seed(1) }),
echo = TRUE,
echo_input = FALSE
)
```
# palettes <a href='https://mccarthy-m-g.github.io/palettes/'><img src='man/figures/logo.png' align="right" height="139"/></a>
<!-- badges: start -->
[![R-CMD-check](https://github.com/mccarthy-m-g/palettes/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/mccarthy-m-g/palettes/actions/workflows/R-CMD-check.yaml)
[![Codecov test coverage](https://codecov.io/gh/mccarthy-m-g/palettes/branch/main/graph/badge.svg)](https://app.codecov.io/gh/mccarthy-m-g/palettes?branch=main)
[![CRAN status](https://www.r-pkg.org/badges/version/palettes)](https://CRAN.R-project.org/package=palettes)
[![R-universe status](https://mccarthy-m-g.r-universe.dev/badges/palettes)](https://mccarthy-m-g.r-universe.dev/palettes)
[![CRAN downloads](https://cranlogs.r-pkg.org/badges/grand-total/palettes)](https://cran.r-project.org/package=palettes)
<!-- badges: end -->
palettes is an R package for working with colour vectors and colour palettes. There are three main goals to the palettes package, each described in a vignette:
- To provide a new family of colour classes (`palettes_colour` and `palettes_palette`) that always print as hex codes with colour previews; `vignette("palettes")`.
- To provide a comprehensive library of methods for working with colour vectors and colour palettes, including methods for ggplot2, `vignette("ggplot2")`; gt, `vignette("gt")`; biscale, `vignette("biscale")`; and other colour packages, `vignette("compatibility")`.
- To make it easy for anyone to make their own colour palette package; `vignette("creating-packages")`. Colour palette packages made with palettes exist solely for the purpose of distributing colour palettes and get access to all the features of palettes for free.
## Installation
Install palettes from [CRAN](https://CRAN.R-project.org/package=palettes) with:
```r
install.packages("palettes")
```
Install the development version from [GitHub](https://github.com/mccarthy-m-g/palettes) or [R-universe](https://mccarthy-m-g.r-universe.dev/palettes) with:
```r
# Install from GitHub
# install.packages("remotes")
remotes::install_github("mccarthy-m-g/palettes")
# Install from R-universe
install.packages("palettes", repos = "https://mccarthy-m-g.r-universe.dev")
```
Install the [WebAssembly](https://webassembly.org) version for use in [WebR](https://docs.r-wasm.org/webr/latest/) applications with:
```r
# Install CRAN version from r-wasm
install.packages("palettes", repos = "https://repo.r-wasm.org")
# Install development version from R-universe
install.packages(
"palettes",
repos = c("https://mccarthy-m-g.r-universe.dev", "https://repo.r-wasm.org")
)
```
## Usage
```{r}
library(palettes)
```
Colours can be specified by name (as listed by `grDevices::colours()`):
```{asciicast pal-colour-character}
pal_colour("red")
```
Or by hex code:
```{asciicast pal-colour-hex}
pal_colour("#FF0000")
```
Multiple colours can be specified at once as a character vector:
```{asciicast pal-colour-vector}
pal_colour(c("#a00e00", "#d04e00", "#f6c200", "#0086a8", "#132b69"))
```
Named colour palettes can be specified in the same way:
```{asciicast pal-palette}
pal_palette(
egypt = c("#dd5129", "#0f7ba2", "#43b284", "#fab255"),
java = c("#663171", "#cf3a36", "#ea7428", "#e2998a", "#0c7156")
)
```
Colours also print nicely in tibbles:
```{asciicast tibble}
as_tibble(pal_colour(c("#dd5129", "#0f7ba2", "#43b284", "#fab255")))
```
## Documentation
See at [`https://mccarthy-m-g.github.io/palettes/`](https://mccarthy-m-g.github.io/palettes/reference/index.html) and also in the installed package: `help(package = "palettes")`.
## License
MIT © Michael McCarthy