Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nowosad/rcartocolor
Implementation of the CARTOcolor palettes in R
https://github.com/nowosad/rcartocolor
color-palette ggplot2 package r visualization
Last synced: 4 days ago
JSON representation
Implementation of the CARTOcolor palettes in R
- Host: GitHub
- URL: https://github.com/nowosad/rcartocolor
- Owner: Nowosad
- License: other
- Created: 2017-10-22T14:33:58.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2024-10-10T11:08:22.000Z (3 months ago)
- Last Synced: 2024-12-15T20:09:59.766Z (11 days ago)
- Topics: color-palette, ggplot2, package, r, visualization
- Language: R
- Homepage: https://jakubnowosad.com/rcartocolor/
- Size: 3.66 MB
- Stars: 110
- Watchers: 4
- Forks: 7
- Open Issues: 0
-
Metadata Files:
- Readme: README.Rmd
- License: LICENSE
- Codemeta: codemeta.json
Awesome Lists containing this project
README
---
output: github_document
---```{r, echo = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
fig.height = 4
)
```# rcartocolor
[![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)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)