-
Notifications
You must be signed in to change notification settings - Fork 1
/
README.Rmd
120 lines (86 loc) · 2.71 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
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%",
fig.retina = 3
)
```
# colorhex
<!-- badges: start -->
[![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)
<!-- badges: end -->
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 released version of colorhex from [CRAN](https://CRAN.R-project.org) with: -->
<!-- ``` r -->
<!-- install.packages("colorhex") -->
<!-- ``` -->
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")
```