Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/christopherkenny/palette
Color Scheme Helpers
https://github.com/christopherkenny/palette
Last synced: 4 months ago
JSON representation
Color Scheme Helpers
- Host: GitHub
- URL: https://github.com/christopherkenny/palette
- Owner: christopherkenny
- License: other
- Created: 2024-03-10T04:40:41.000Z (12 months ago)
- Default Branch: main
- Last Pushed: 2024-06-13T17:39:04.000Z (8 months ago)
- Last Synced: 2024-10-12T12:18:35.861Z (4 months ago)
- Language: R
- Homepage: http://christophertkenny.com/palette/
- Size: 6.81 MB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.Rmd
- License: LICENSE
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%'
)
```# palette
[](https://CRAN.R-project.org/package=palette)
[](https://github.com/christopherkenny/palette/actions/workflows/R-CMD-check.yaml)
[](https://lifecycle.r-lib.org/articles/stages.html#stable)
[](https://christopherkenny.r-universe.dev/palette)
[](https://app.codecov.io/gh/christopherkenny/palette?branch=main)`palette` provides a lightweight infrastructure for working with color palettes in R.
The primary goal is to place colors directly next to their character representations.
To do this, we create a palette class based on [`vctrs`](https://vctrs.r-lib.org/index.html).
We then provide methods for this class, including `print()`, `plot()`, and [`pillar`](https://pillar.r-lib.org/).
To keep it lightweight and usable in other packages, the only direct dependencies are `vctrs`, `cli`, and `pillar`.## Installation
You can install the development version of palette from [GitHub](https://github.com/) with:
``` r
# install.packages('pak')
pak::pak('christopherkenny/palette')
```## Using `palette`
`palette` primarily provides a `palette` `vctrs` class.
Using included data, `roygbiv`, a length 7 vector of hex codes, we can create a palette.```{r print, results = 'hide'}
library(palette)
palette(roygbiv)
```![]()
There is also a `plot()` method for visualizing the colors:
```{r plot}
plot(palette(roygbiv))
```For use within `tibble`s, there is a `pillar_shaft` method:
```{r pillar, eval = FALSE}
tibble::tibble(
color = palette(roygbiv)
)
```![]()