-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathREADME.Rmd
115 lines (84 loc) · 3.68 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
---
output: github_document
---
```{r, echo = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "tools/"
)
```
## cetcolor
<!-- badges: start -->
[![R-CMD-check](https://github.com/coatless-rpkg/cetcolor/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/coatless-rpkg/cetcolor/actions/workflows/R-CMD-check.yaml)
[![CRAN_Status_Badge](http://www.r-pkg.org/badges/version/cetcolor)](https://cran.r-project.org/package=cetcolor)
[![CRAN RStudio mirror downloads](https://cranlogs.r-pkg.org/badges/cetcolor)](https://www.r-pkg.org/pkg/cetcolor)
<!-- badges: end -->
The [`cetcolor`](https://cran.r-project.org/package=cetcolor) package is designed
to bring to _R_ the 56 colour maps created by [Peter Kovesi](https://colorcet.com/)
that avoid points of locally high colour contrast leading to the perception of
false anomalies in your data when there is none. The colour maps have been
designed to avoid this phenomenon by having uniform perceptual contrast over
their whole range.
### Installation
The `cetcolor` package is available on both CRAN and GitHub. The CRAN
version is considered stable while the GitHub version is in a state of
development and may break.
You can install the stable version of the `cetcolor` package with:
```r
install.packages("cetcolor")
```
For the development version, you can opt for:
```r
install.packages("remotes")
remotes::install_github("coatless-rpkg/cetcolor")
```
### Sample Usage
```{r ggplot_example}
# Load the Library
library("cetcolor")
# Get RGB Hexadecimals for graphing
cet_pal(5, name = "blues")
# Sample use with ggplot2
library("ggplot2")
ggplot(faithfuld, aes(waiting, eruptions)) +
geom_raster(aes(fill = density)) +
theme_bw() + theme(panel.grid=element_blank()) -> g
library("gridExtra")
# Frequently used colour maps have "nicknames" see ?cet_color_maps
grid.arrange(
g + scale_fill_gradientn(colours = cet_pal(5, name = "fire")),
g + scale_fill_gradientn(colours = cet_pal(5, name = "inferno")),
g + scale_fill_gradientn(colours = cet_pal(5, name = "blues")),
g + scale_fill_gradientn(colours = cet_pal(5, name = "kgy")),
ncol = 2, nrow = 2
)
```
```{r colordemo, fig.width = 8, fig.height = 15}
# Show a panel of possible values (without nicknames)
display_cet_all()
```
## References
### CET
- [CET Perceptually Uniform Colour Maps: Download Page](https://colorcet.com/)
- Location of CSV data, references, and data.
- [colorcet for Python](https://github.com/bokeh/colorcet)
- Shorthand naming of colour schemes and presentation of palettes
- [PerceptualColourMaps.jl by Peter Kovesi](https://github.com/peterkovesi/PerceptualColourMaps.jl)
- Referenced documentation and possible reimplementation of generation
functions to avoid using CSV data.
### R Colour Palettes
- [`viridis`](https://cran.r-project.org/package=viridis) ([Source](https://github.com/sjmgarnier/viridis))
- Provides MATLAB perceptually uniform colour maps in a manner that is similar to this package.
- [`RColorBrewer`](https://cran.r-project.org/package=RColorBrewer) ([Source](RColorBrewer))
- Function interface naming, e.g. `cet_pal(n, name)`, and colour map displays.
- [`scales`](https://github.com/hadley/scales/blob/646b6a433e6f7106bed4173569898fac409d22b5/R/pal-brewer.r) and [`ggplot2`](https://github.com/tidyverse/ggplot2/blob/f6f9f9de41c48382c70cbccc253db198e3cdc128/R/scale-brewer.r)
- Proper ways to interface colour palettes with `ggplot2` as shown for `RColorBrewer`.
## Future
- Allow for n > 256.
- Provide hooks for ggplot2 gradient and discrete scales
- Port over the Peter's generation code from Julia / MATLAB to R.
## Authors
James Balamuta and Peter Kovesi
## License
CC BY-SA 4.0