Type: Package
Title: A Set of Color Palettes Inspired by OK Go Music Videos for 'ggplot2' in R
Version: 0.1.0
Description: A collection of aesthetically appealing color palettes for effective data visualization with 'ggplot2'. Palettes support both discrete and continuous data.
License: GPL-3
Encoding: UTF-8
Imports: ggplot2 (≥ 3.0.0)
Suggests: testthat (≥ 3.0.0), knitr, rmarkdown
URL: https://github.com/nelsonquesado/okcolors
BugReports: https://github.com/nelsonquesado/okcolors/issues
Depends: R (≥ 3.5.0)
RoxygenNote: 7.3.2
NeedsCompilation: no
Packaged: 2025-05-12 11:36:11 UTC; nelsonquesado
Author: Nelson de O. Quesado Filho [aut, cre], Ana Flávia Teles Silveira [aut]
Maintainer: Nelson de O. Quesado Filho <nquesado@gmail.com>
Repository: CRAN
Date/Publication: 2025-05-14 08:10:02 UTC

Retrieve a Color Palette from the okcolors package

Description

Returns a vector of 'n' colors from a specified palette included in the okcolors package.

Usage

okcolors(palette = "obsession", n = 5)

Arguments

palette

Character. Name of the palette to use. One of '"it"', '"stone"', '"skyscrapers"', '"obsession"', or '"moment"'. Default is '"obsession"'.

n

Integer. Number of colors to return. Default is '5'.

Details

The available palettes are:

Value

A character vector of hex color codes of length 'n'.

Examples

okcolors("stone", 3)
okcolors("obsession", 7)


Custom ggplot2 Color Scale using okcolors Palettes

Description

Applies a custom discrete or continuous color scale to ggplot2 plots using a selected palette from the okcolors package.

Usage

scale_color_okcolors(palette = "obsession", discrete = TRUE, ...)

Arguments

palette

Character. Name of the palette to use. Must be one of the palettes available in 'okcolors()'. Default is '"obsession"'.

discrete

Logical. Whether to use a discrete scale ('TRUE') or a continuous scale ('FALSE'). Default is 'TRUE'.

...

Additional arguments passed to 'ggplot2::discrete_scale()' or 'ggplot2::scale_color_gradientn()'.

Value

A 'Scale' object that can be added to a ggplot2 plot.

Examples

library(ggplot2)
ggplot2::ggplot(ggplot2::mpg, ggplot2::aes(displ, hwy, color = class)) +
  ggplot2::geom_point(size = 3) +
  scale_color_okcolors("obsession")

ggplot2::ggplot(ggplot2::mpg, ggplot2::aes(displ, hwy, color = hwy)) +
  ggplot2::geom_point(size = 3) +
  scale_color_okcolors("skyscrapers", discrete = FALSE)


Custom ggplot2 Fill Scale using okcolors Palettes

Description

Applies a custom discrete or continuous fill scale to ggplot2 plots using a selected palette from the okcolors package.

Usage

scale_fill_okcolors(palette = "obsession", discrete = TRUE, ...)

Arguments

palette

Character. Name of the palette to use. Must be one of the palettes available in 'okcolors()'. Default is '"obsession"'.

discrete

Logical. Whether to use a discrete scale ('TRUE') or a continuous scale ('FALSE'). Default is 'TRUE'.

...

Additional arguments passed to 'ggplot2::discrete_scale()' or 'ggplot2::scale_fill_gradientn()'.

Value

A 'Scale' object that can be added to a ggplot2 plot.

Examples

ggplot2::ggplot(ggplot2::mpg, ggplot2::aes(class, fill = class)) +
  ggplot2::geom_bar() +
  scale_fill_okcolors("skyscrapers")

ggplot2::ggplot(ggplot2::mpg, ggplot2::aes(displ, hwy, fill = hwy)) +
  ggplot2::geom_tile() +
  scale_fill_okcolors("obsession", discrete = FALSE)