MyNixOS website logo
Description

Star Trek Color Palettes.

Provides a dataset of predefined color palettes based on the Star Trek science fiction series, associated color palette functions, and additional functions for generating customized palettes that are on theme. The package also offers functions for applying the palettes to plots made using the 'ggplot2' package.

trekcolors

Author:Matthew LeonawiczORCID logo
License:MIT

Project Status: Active – The project has reached a stable, usablestate and is being activelydeveloped. Travis buildstatus AppVeyor buildstatus Codecov testcoverage

CRANstatus CRANdownloads GithubStars

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

install.packages("trekcolors")

Install the development version from GitHub with

# install.packages("remotes")
remotes::install_github("leonawicz/trekcolors")

Examples

Basics

library(trekcolors)
library(ggplot2)

trek_pal("starfleet")
#> [1] "#5B1414" "#AD722C" "#1A6384"

trek_pal("lcars_2357")
#> [1] "#FFFF99" "#FFCC99" "#FFCC66" "#FF9933" "#664466" "#CC99CC" "#99CCFF" "#3366CC" "#006699"
lcars_pal("2357") # there are some special functions for LCARS colors
#> [1] "#FFFF99" "#FFCC99" "#FFCC66" "#FF9933" "#664466" "#CC99CC" "#99CCFF" "#3366CC" "#006699"

Preview the starfleet and lcars_2357 palettes.

view_trek_pals(c("starfleet", "lcars_2357"))

Scale functions for use with ggplot2

p <- ggplot(iris, aes(Sepal.Width, Sepal.Length, color = Species)) + 
  geom_point(size = 5, alpha = 0.75)
p + scale_color_trek() # starfleet is default palette

p <- 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.

# lcars_pals() # print list of all LCARS palettes

lcars_colors() # full set of unique names across the four palettes
#>      pale-canary            tanoi     golden-tanoi      neon-carrot         eggplant            lilac          anakiwa          mariner      bahama-blue        blue-bell 
#>        "#FFFF99"        "#FFCC99"        "#FFCC66"        "#FF9933"        "#664466"        "#CC99CC"        "#99CCFF"        "#3366CC"        "#006699"        "#9999CC" 
#>          melrose          hopbush    chestnut-rose      orange-peel atomic-tangerine            danub           indigo  lavender-purple           cosmic       red-damask 
#>        "#9999FF"        "#CC6699"        "#CC6666"        "#FF9966"        "#FF9900"        "#6688CC"        "#4455BB"        "#9977AA"        "#774466"        "#DD6644" 
#>   medium-carmine          bourbon      sandy-brown       periwinkle      dodger-pale      dodger-soft        near-blue        navy-blue             husk             rust 
#>        "#AA5533"        "#BB6622"        "#EE9955"        "#CCDDFF"        "#5599FF"        "#3366FF"        "#0011EE"        "#000088"        "#BBAA55"        "#BB4411" 
#>        tamarillo 
#>        "#882211"

lcars_2357() # specific color series; also 2369, 2375, 2379
#>  pale-canary        tanoi golden-tanoi  neon-carrot     eggplant        lilac      anakiwa      mariner  bahama-blue 
#>    "#FFFF99"    "#FFCC99"    "#FFCC66"    "#FF9933"    "#664466"    "#CC99CC"    "#99CCFF"    "#3366CC"    "#006699"

lcars_2357("lilac", "mariner") # select by name
#>     lilac   mariner 
#> "#CC99CC" "#3366CC"

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.

lcars_custom_pal <- lcars_colors_pal(c("pale-canary", "eggplant"))
lcars_custom_pal(8)
#> [1] "#FFFF99" "#E9E491" "#D3C98A" "#BDAE83" "#A7947B" "#917974" "#7B5E6D" "#664466"

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

# See available palette names
trek_pal()
#>  [1] "andorian"            "bajoran"             "borg"                "breen"               "breen2"              "dominion"            "enara"               "enara2"             
#>  [9] "ferengi"             "gorn"                "iconian"             "klingon"             "lcars_series"        "lcars_2357"          "lcars_2369"          "lcars_2375"         
#> [17] "lcars_2379"          "lcars_alt"           "lcars_first_contact" "lcars_nemesis"       "lcars_nx01"          "lcars_29c"           "lcars_23c"           "lcars_red_alert"    
#> [25] "lcars_cardassian"    "romulan"             "romulan2"            "starfleet"           "starfleet2"          "tholian"             "terran"              "ufp"                
#> [33] "red_alert"           "yellow_alert"        "black_alert"

# 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.


trekfont: A fonts package

True (Trek) type fonts to style your Star Trek themed graphics text.


Citation

Matthew Leonawicz (2021). trekcolors: Star Trek Color Palettes. R package version 0.1.3. 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. By contributing to this project, you agree to abide by its terms.

Metadata

Version

0.1.3

License

Unknown

Platforms (77)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-freebsd
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64-windows
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows