Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/leonawicz/trekcolors
Strak Trek color palettes
https://github.com/leonawicz/trekcolors
color-palettes lcars r-package star-trek
Last synced: 15 days ago
JSON representation
Strak Trek color palettes
- Host: GitHub
- URL: https://github.com/leonawicz/trekcolors
- Owner: leonawicz
- License: other
- Created: 2019-07-05T06:28:16.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2024-09-11T22:38:21.000Z (3 months ago)
- Last Synced: 2024-09-13T08:14:56.440Z (3 months ago)
- Topics: color-palettes, lcars, r-package, star-trek
- Language: R
- Homepage: https://leonawicz.github.io/trekcolors/
- Size: 5.14 MB
- Stars: 26
- Watchers: 7
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.Rmd
- Changelog: NEWS.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
- Codemeta: codemeta.json
Awesome Lists containing this project
- jimsghstars - leonawicz/trekcolors - Strak Trek color palettes (R)
README
---
output: github_document
---```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE, comment = "#>", fig.path = "man/figures/README-",
fig.height = 3, out.width = "100%", dpi = 150, message = FALSE,
warning = FALSE, error = FALSE, dev.args = list(type = "cairo")
)
```# trekcolors
[![Project Status: Active – The project has reached a stable, usable state and is being actively developed.](https://www.repostatus.org/badges/latest/active.svg)](https://www.repostatus.org/)
[![R-CMD-check](https://github.com/leonawicz/trekcolors/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/leonawicz/trekcolors/actions/workflows/R-CMD-check.yaml)
[![Codecov test coverage](https://codecov.io/gh/leonawicz/trekcolors/graph/badge.svg)](https://app.codecov.io/gh/leonawicz/trekcolors)
[![CRAN status](https://www.r-pkg.org/badges/version/trekcolors)](https://CRAN.R-project.org/package=trekcolors)
[![CRAN downloads](https://cranlogs.r-pkg.org/badges/grand-total/trekcolors)](https://cran.r-project.org/package=trekcolors)
[![Github Stars](https://img.shields.io/github/stars/leonawicz/trekcolors.svg?style=social&label=Github)](https://github.com/leonawicz/trekcolors)The `trekcolors` package provides a collection of color palettes based on Star Trek. It also offers functions for custom palettes and `scale_*` functions for use with `ggplot2`.
## Installation
Install the CRAN release of `trekcolors` with
```r
install.packages("trekcolors")
```Install the development version from GitHub with
```r
# install.packages("remotes")
remotes::install_github("leonawicz/trekcolors")
```## Examples
### Basics
```{r ex1}
library(trekcolors)
library(ggplot2)trek_pal("starfleet")
trek_pal("lcars_2357")
lcars_pal("2357") # there are some special functions for LCARS colors
```Preview the `starfleet` and `lcars_2357` palettes.
```{r ex2}
view_trek_pals(c("starfleet", "lcars_2357"))
```### Scale functions for use with ggplot2
```{r ex3}
p <- ggplot(iris, aes(Sepal.Width, Sepal.Length, color = Species)) +
geom_point(size = 5, alpha = 0.75)
p + scale_color_trek() # starfleet is default palettep <- ggplot(diamonds, aes(carat, price, color = clarity)) +
geom_point()
p + scale_color_lcars("2357") # equivalent to scale_color_trek("lcars_2357")p <- ggplot(diamonds, aes(carat, stat(count), fill = cut)) +
geom_density(position = "fill")
p + scale_fill_trek("klingon")
p + scale_fill_trek("romulan")
p + scale_fill_trek("andorian")p <- ggplot(diamonds, aes(carat, stat(count), fill = cut)) +
geom_density(position = "fill")
p + scale_fill_lcars("2357")
p + scale_fill_lcars1("atomic-tangerine", dark = TRUE)
p + scale_fill_lcars2("pale-canary", "danub")d <- diamonds[diamonds$cut >= "Very Good", ]
p <- ggplot(d, aes(carat, stat(count), fill = cut)) +
geom_density(position = "fill")
p + scale_fill_trek("starfleet")
```### Palettes with named colors
The four LCARS palettes that have a year in their series name are special in that these official standard LCARS colors have formal names.
```{r ex4}
# lcars_pals() # print list of all LCARS paletteslcars_colors() # full set of unique names across the four palettes
lcars_2357() # specific color series; also 2369, 2375, 2379
lcars_2357("lilac", "mariner") # select by name
```### Custom palettes
In addition to these and all the other predefined palettes, custom palettes can be constructed using official LCARS color names. This is like `colorRampPalette()` but with the ability to recognize official LCARS color names. This functionality was leveraged by `scale_color_lcars1()` and `scale_color_lcars2()` seen above when making sequential or divergent palettes based on specific LCARS colors for use with ggplot.
```{r ex5}
lcars_custom_pal <- lcars_colors_pal(c("pale-canary", "eggplant"))
lcars_custom_pal(8)p <- ggplot(diamonds, aes(carat, stat(count), fill = cut)) +
geom_density(position = "fill")
p + scale_fill_lcars2("pale-canary", "danub")# p + scale_fill_manual(values = lcars_custom_pal(8)) # equivalent
p + scale_fill_lcars2("pale-canary", "danub", divergent = TRUE)
p + scale_fill_lcars2("pale-canary", "danub", dark = TRUE, divergent = TRUE)
```### All predefined palettes
```{r ex6, fig.width=6, fig.height=8}
# See available palette names
trek_pal()# view all predefined palettes
view_trek_pals()
```## Packages in the trekverse
rtrek: The core Star Trek package
Datasets related to Star Trek, API wrappers to external data sources, and more.
lcars: LCARS aesthetic for Shiny
Create Shiny apps based on the Library Computer Access/Retrieval System (LCARS).
trekcolors: A color palette package
Predefined and customizable Star Trek themed color palettes and related functions.
## Citation
Matthew Leonawicz (`r substr(Sys.Date(), 1, 4)`). trekcolors: Star Trek Color Palettes. R package version 0.2.0. https://CRAN.R-project.org/package=trekcolors
## Contribute
Contributions are welcome. Contribute through GitHub via pull request. Please create an issue first if it is regarding any substantive feature add or change.
---
Please note that the `trekcolors` project is released with a [Contributor Code of Conduct](https://github.com/leonawicz/trekcolors/blob/master/CODE_OF_CONDUCT.md). By contributing to this project, you agree to abide by its terms.