Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/drmowinckels/colorhex


https://github.com/drmowinckels/colorhex

color-hex color-picker colors r rstats rstats-package

Last synced: 6 days ago
JSON representation

Awesome Lists containing this project

README

        

---
output: github_document
---

```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%",
fig.retina = 3
)
```

# colorhex

[![CRAN status](https://www.r-pkg.org/badges/version/colorhex)](https://CRAN.R-project.org/package=colorhex)
[![R-CMD-check](https://github.com/drmowinckels/colorhex/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/drmowinckels/colorhex/actions/workflows/R-CMD-check.yaml)

The goal of colorhex is to create an interface to [color-hex.com](https://www.color-hex.com/), a website with hexidecimal colors and information about them.

It also has lots of user-made palettes that can be used and browsed.

## Installation

You can install the development version from [GitHub](https://github.com/) with:

``` r
# install.packages("remotes")
remotes::install_github("drmowinckels/colorhex", ref = "main")
```
## Example

### Single colors

```{r example, fig.width = 12}
library(colorhex)

x <- get_color("#470f0f")
x
plot(x)
```

```{r "pop-cols", , fig.width = 12, fig.height=12}
x <- get_popular_colors()
x
scales::show_col(x)
```

### Palettes

```{r "latest", fig.height=10}
latest <- get_latest_palettes()
plot(latest)
```

```{r "popular-palettes", fig.height=12}
popular <- get_popular_palettes()
plot(popular)
```

### ggplot2 scales
```{r warning=FALSE}
library(ggplot2)

ggplot(mtcars, aes(mpg)) +
geom_density(aes(fill = disp, group = disp)) +
scale_fill_palettehex_c(popular)

ggplot(mtcars, aes(mpg)) +
geom_density(aes(fill = disp, group = disp)) +
scale_fill_palettehex_c(popular, 3)

ggplot(mtcars, aes(mpg, disp, colour = factor(cyl))) +
geom_point() +
scale_color_palettehex_d(popular)

ggplot(mtcars, aes(mpg, disp, colour = factor(cyl))) +
geom_point() +
scale_color_palettehex_d(popular, 1872)
```

```{r warning=FALSE}
x <- get_color("#008080")

ggplot(mtcars, aes(mpg)) +
geom_density(aes(fill = disp, group = disp)) +
scale_fill_colorhex_c(x)

ggplot(mtcars, aes(mpg)) +
geom_density(aes(fill = disp, group = disp)) +
scale_fill_colorhex_c(x, "tints")

ggplot(mtcars, aes(mpg)) +
geom_density(aes(fill = disp, group = disp)) +
scale_fill_colorhex_c(x, "shades")

ggplot(mtcars, aes(mpg, disp, colour = factor(cyl))) +
geom_point() +
scale_color_colorhex_d(x, "triadic")

ggplot(mtcars, aes(mpg, disp, colour = factor(cyl))) +
geom_point() +
scale_color_colorhex_d(x, "shades")
```