-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathREADME.Rmd
98 lines (72 loc) · 2.83 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
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, echo = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
fig.height = 4
)
```
# rcartocolor <img src="man/figures/logo.png" align="right" height="150" alt="" />
<!-- badges: start -->
[![R-CMD-check](https://github.com/Nowosad/rcartocolor/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/Nowosad/rcartocolor/actions/workflows/R-CMD-check.yaml)
[![codecov](https://codecov.io/gh/Nowosad/rcartocolor/branch/master/graph/badge.svg?token=tkiSWsEUYy)](https://codecov.io/gh/Nowosad/rcartocolor)
[![CRAN_Status_Badge](https://www.r-pkg.org/badges/version/rcartocolor)](https://cran.r-project.org/package=rcartocolor)
[![CRAN RStudio mirror downloads](https://cranlogs.r-pkg.org/badges/rcartocolor)](https://cran.r-project.org/package=rcartocolor)
<!-- badges: end -->
The goal of `rcartocolor` is to provide color schemes for maps and other graphics designed by [CARTO](https://carto.com/) as described at https://carto.com/carto-colors/.
## Installation
Get the released version from CRAN:
```{r cran-installation, eval = FALSE}
install.packages("rcartocolor")
```
Get the development version from github:
```{r gh-installation, eval = FALSE}
# install.packages("remotes")
remotes::install_github("Nowosad/rcartocolor")
```
## Examples
Display a CARTOcolor palette:
```{r example}
library(rcartocolor)
display_carto_pal(7, "Vivid")
```
Create a CARTOcolor palette:
```{r example2}
my_colors = carto_pal(7, "Burg")
my_colors
```
Display all of the CARTOcolor palettes:
```{r example3, fig.height=7, fig.width=6}
display_carto_all()
```
[Only display colorblind friendly palettes](https://jakubnowosad.com/colorblindcheck/articles/check_rcartocolor.html):
```{r example4, fig.height=6, fig.width=6}
display_carto_all(colorblind_friendly = TRUE)
```
### **ggplot2**
The **rcartocolor** package contains four **ggplot2** color scales: two for continuous data - `scale_fill_carto_c`, `scale_color_carto_c` and two for discrete data - `scale_fill_carto_d`, `scale_color_carto_d`:
```{r examplegg1}
# devtools::install_github("tidyverse/ggplot2")
library(sf)
library(spData)
library(ggplot2)
ggplot(world, aes(fill = lifeExp)) +
geom_sf(data = world) +
coord_sf(crs = "+proj=robin") +
scale_fill_carto_c(name = "Life expectancy: ",
type = "diverging", palette = "Earth", direction = -1) +
theme_void()
```
```{r examplegg2}
ggplot(world, aes(fill = region_un)) +
geom_sf(data = world) +
coord_sf(crs = "+proj=robin") +
scale_fill_carto_d(name = "Region: ", palette = "Safe") +
theme_void()
```
## Contributions
[Feel free to submit issues and enhancement requests.](https://github.com/Nowosad/rcartocolor/issues)