Learn R Programming

hues (version 0.2.0)

hues-ggplot2-scales: iwanthue scales to use with ggplot2

Description

These functions allow you to use iwanthue() generated palettes with ggplot2 plots. You need ggplot2 installed for these to work. Note these only work with discrete scales.

Usage

scale_colour_iwanthue(
  ...,
  hmin = 0,
  hmax = 360,
  cmin = 0,
  cmax = 180,
  lmin = 0,
  lmax = 100,
  random = FALSE,
  aesthetics = "colour"
)

scale_color_iwanthue( ..., hmin = 0, hmax = 360, cmin = 0, cmax = 180, lmin = 0, lmax = 100, random = FALSE, aesthetics = "colour" )

scale_fill_iwanthue( ..., hmin = 0, hmax = 360, cmin = 0, cmax = 180, lmin = 0, lmax = 100, random = FALSE, aesthetics = "fill" )

Arguments

...

Arguments to pass on to ggplot2::discrete_scale().

hmin

Numeric, in the range [0, 360]. The lower limit of the hue range to be clustered.

hmax

Numeric, in the range [0, 360]. The upper limit of the hue range to be clustered.

cmin

Numeric, in the range [0, 180]. The lower limit of the chroma range to be clustered.

cmax

Numeric, in the range [0, 180]. The upper limit of the chroma range to be clustered.

lmin

Numeric, in the range [0, 100]. The lower limit of the luminance range to be clustered.

lmax

Numeric, in the range [0, 100]. The upper limit of the luminance range to be clustered.

random

Logical. If TRUE, clustering will be determined by the existing RNG state. If FALSE, the seed will be set to 1 for clustering, and on exit, the function will restore the pre-existing RNG state.

aesthetics

Character string or vector of character strings listing the name(s) of the aesthetic(s) that this scale works with. This can be useful, for example, to apply colour settings to the colour and fill aesthetics at the same time, via aesthetics = c("colour", "fill").

Value

A ScaleDiscrete object that can be added to a ggplot object.

Examples

Run this code
# NOT RUN {
if (require('ggplot2')) {

   ggplot(iris, aes(x=Petal.Width, y=Petal.Length)) +
     geom_point(aes(color=Species), size=10) + 
     scale_colour_iwanthue()
    
   ggplot(iris, aes(x=Petal.Width, y=Petal.Length)) +
     geom_point(aes(color=Species), size=10) + 
     scale_colour_iwanthue(hmax = 90)
     
}
# }

Run the code above in your browser using DataLab