Title: | Star Trek Color Palettes |
Version: | 0.2.0 |
Description: | 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. |
License: | MIT + file LICENSE |
URL: | https://github.com/leonawicz/trekcolors |
BugReports: | https://github.com/leonawicz/trekcolors/issues |
Depends: | R (≥ 2.10) |
Imports: | ggplot2 |
Suggests: | testthat, knitr, rmarkdown, covr |
Encoding: | UTF-8 |
Language: | en-US |
LazyData: | true |
RoxygenNote: | 7.3.2 |
NeedsCompilation: | no |
Packaged: | 2024-09-11 22:24:02 UTC; Matt |
Author: | Matthew Leonawicz |
Maintainer: | Matthew Leonawicz <rpkgs@pm.me> |
Repository: | CRAN |
Date/Publication: | 2024-09-12 17:40:09 UTC |
trekcolors: Star Trek Color Palettes
Description
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.
Author(s)
Maintainer: Matthew Leonawicz rpkgs@pm.me (ORCID)
See Also
Useful links:
Report bugs at https://github.com/leonawicz/trekcolors/issues
Hex colors from LCARS color names
Description
Obtain hex colors from standard LCARS color names.
Usage
lcars_colors(...)
lcars_2357(...)
lcars_2369(...)
lcars_2375(...)
lcars_2379(...)
Arguments
... |
character, LCARS color names. |
Details
These functions return the hex colors for LCARS color names. If no argument
is provided, the functions return their respective LCARS color set.
These functions correspond to LCARS color palettes that contain named colors.
Other predefined LCARS color palettes are available but do not have names for
each color. You can see all LCARS palettes with lcars_pals()
.
See Also
Examples
lcars_colors()
lcars_2357()
lcars_colors("rust", "danub")
Palettes and palette generating functions based on LCARS colors
Description
Predefined and custom palettes based on LCARS colors.
Usage
lcars_pals()
lcars_pal(palette = "2357", reverse = FALSE)
lcars_colors_pal(palette, reverse = FALSE, ...)
Arguments
palette |
character, name of a single predefined LCARS palette; or a vector of LCARS or other colors. See details. |
reverse |
logical, reverse color order. |
... |
additional arguments to pass to |
Details
lcars_pal()
returns a predefined, qualitative LCARS color palette.
lcars_color_pal()
returns a palette generator based on specific colors.
lcars_pals()
is a function that takes no arguments and returns a list of
all predefined LCARS palettes.
Predefined palettes options for palette
are "2357"
, "2369"
, "2375"
,
"2379"
, "alt"
, "first_contact"
, "nemesis"
, "nx01"
, "23c"
, "29c"
,
"red_alert"
and "cardassian"
.
Custom palettes can also be constructed by passing a vector of colors to
palette
in lcars_color_pal()
. This is useful for sequential and divergent
palettes. This is essentially a wrapper around colorRampPalette()
that
understands LCARS color names. It accepts any color, allowing you to still
use a color like "white"
or "#FFFFFF"
as the midpoint in a divergent
palette for example. A special case is when you provide only a single color,
e.g., lcars_color_pal("husk")
; this is equivalent to
lcars_color_pal(c("white", "husk"))
.
Value
a palette generating function that takes an argument, n
, the number
of colors.
Examples
# All predefined LCARS palettes
lcars_pals()
# predefined palette
lcars_pal("2357")
# custom palettes
lcars_colors_pal("rust")(8) # sequential
lcars_colors_pal(c("pale-canary", "rust"))(8)
lcars_colors_pal(c("pale-canary", "rust"))(4)
lcars_colors_pal(c("mariner", "white", "rust"))(9) # divergent
Color and fill scale functions for LCARS colors
Description
Scale functions used with ggplot2.
Usage
scale_color_lcars(palette = "2357", discrete = TRUE, reverse = FALSE, ...)
scale_color_lcars1(
color = "atomic-tangerine",
discrete = TRUE,
reverse = FALSE,
dark = FALSE,
...
)
scale_color_lcars2(
low = "atomic-tangerine",
high = "near-blue",
discrete = TRUE,
reverse = FALSE,
dark = FALSE,
divergent = FALSE,
...
)
scale_fill_lcars(palette = "2357", discrete = TRUE, reverse = FALSE, ...)
scale_fill_lcars1(
color = "atomic-tangerine",
discrete = TRUE,
reverse = FALSE,
dark = FALSE,
...
)
scale_fill_lcars2(
low = "atomic-tangerine",
high = "near-blue",
discrete = TRUE,
reverse = FALSE,
dark = FALSE,
divergent = FALSE,
...
)
Arguments
palette |
character, name of palette in |
discrete |
logical, discrete or continuous palette. |
reverse |
logical, reverse color order. |
... |
additional arguments passed to |
color |
character, LCARS color name for sequential palette. |
dark |
logical, use black instead of white for the base color in sequential palette or midpoint in divergent palette. |
low |
character, LCARS color name. |
high |
character, LCARS color name. |
divergent |
logical, use a divergent palette instead of two-color sequential palette. |
Examples
library(ggplot2)
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")
Color and fill scale functions for Star Trek palettes
Description
Scale functions used with ggplot2.
Usage
scale_color_trek(palette = "starfleet", discrete = TRUE, reverse = FALSE, ...)
scale_fill_trek(palette = "starfleet", discrete = TRUE, reverse = FALSE, ...)
Arguments
palette |
character, name of Star Trek palette. See |
discrete |
logical, discrete or continuous palette. |
reverse |
logical, reverse color order. |
... |
additional arguments passed to |
Details
Most palettes should be used as qualitative palettes. See trekpals
to see
how many colors are in each predefined palette. Use view_trek_pals()
to
plot all palettes to see which may work best for your purposes.
Examples
library(ggplot2)
d <- diamonds[diamonds$cut >= "Very Good", ]
ggplot(d, aes(carat, stat(count), fill = cut)) +
geom_density(position = "fill") +
scale_fill_trek("starfleet")
Star Trek color palettes
Description
Return a predefined Star Trek color palette from the trekpals
dataset.
Usage
trek_pal(palette, reverse = FALSE)
view_trek_pals(palette)
Arguments
palette |
character, name of predefined palette. If missing, return all available palette names. |
reverse |
logical, reverse color order. |
Details
Many of the palettes are qualitative, and not necessarily evenly spaced in terms of hue, saturation or brightness. This is because many palettes come from logos, symbols, insignia and other simple representations. However, several palettes have specifically been constructed as sequential or divergent if it made sense to do so based on the dominant colors present. Additional special functions exist for the subset of LCARS palettes.
Value
character vector of hex colors or palette names
See Also
Examples
trek_pal("lcars_2357")
# leave palette blank to list available names:
trek_pal()
# to view all palettes
view_trek_pals()
Star Trek color palettes.
Description
A named list of 35 Star Trek color palettes.
Usage
trekpals
Format
A named list.