Learn R Programming

unikn (version 0.6.0)

demopal: Demonstrate a color palette.

Description

demopal provides an example plot of some type to illustrate a color palette pal.

Usage

demopal(pal = pal_unikn, type = NA, pal_name = NULL, ...)

Value

The random data that was plotted (as an invisible R object).

Arguments

pal

A color palette (to be illustrated). Default: pal = pal_unikn.

type

The type of plot to be used (as character or integer index). Permissible types are "bar", "mosaic", "scatter" (or 1 to 3).

pal_name

A name for the input color palette pal (shown on bottom-right margin). Default: pal_name = NULL (deparsing to input name).

...

Auxiliary arguments passed to type-specific plots (see details).

Details

The demopal wrapper function passes a range of arguments to more specific functions. Common arguments include:

  • col_par Default color for par(col);

  • alpha Default value for color transparency (in 0:1);

  • n A scaling parameter (for random data generation);

  • main plot title (on top);

  • sub plot subtitle (on right margin);

  • seed A random seed (for reproducible randomness).

Some functions additionally accept type-specific arguments (e.g., beside, horiz, and as_prop, for plot type = "bar", and cex for plot type = "scatter").

The type-specific functions usually generate some random data (scaled by a parameter n) that is being plotted. This data is returned (as an invisible R object) to enable a plot's reconstruction.

See Also

seepal for plotting color palettes; usecol for using color palettes; shades_of to defining shades of a given color; ac for adjusting color transparency; pal_unikn for the default uni.kn color palette.

Other color functions: ac(), grepal(), newpal(), seecol(), shades_of(), simcol(), usecol()

Examples

Run this code
demopal(pal = pal_petrol, type = 1)

my_pal <- c(rev(pal_pinky), pal_seeblau) 
# Selecting plot type:
demopal(my_pal, type = 2)          # by numeric index
demopal(my_pal, type = "polygon")  # by name

# Passing type-specific arguments:
demopal(type = "scatter", col_par = "black", n = 200, cex = c(2, 4, 6), seed = 101)

Run the code above in your browser using DataLab