Plot a color palette in a hyperSpec object, which was added with function hyAdd_color.

plot_hyPalette(
  sp = NULL,
  by = ".color",
  palette = hyGet_palette(sp),
  cex = if (as.legend == FALSE) 1.2 else 1,
  Title = if (!is.null(sp)) "Group colors" else "Colors",
  as.legend = FALSE,
  xpd = NA,
  x = "topright",
  y = NULL,
  bty = "n",
  ...
)

Arguments

sp

hyperSpec object.

by

Either a name of factor variale in sp which levels correspond to colors in palette or, if sp is not present, a charter vector of names to be ploted as a text.

palette

A list of color names or color codes.

cex

character expansion factor relative to current par("cex"). Used for text, and provides the default for pt.cex.

Title

The title.

as.legend

Logical. If TRUE, the result is used as legend for existing R base graphics plot. If FALSE (default), a separate plot is drawn.

xpd

A logical value or NA. If FALSE, all plotting is clipped to the plot region, if TRUE, all plotting is clipped to the figure region, and if NA, all plotting is clipped to the device region. See also clip.

x, y

the x and y co-ordinates to be used to position the legend. They can be specified by keyword or in any way which is accepted by xy.coords: See "Details" in legend.

bty

The type of box to be drawn around the legend. The allowed values are "o" and "n" (the default).

...

Other arguments to be passed to legend. (except legend, title and fill)

Value

A plot made with R package graphics.

Author

Vilmantas Gegzna

Examples


# Example 1
sp <- hyAdd_color(Spectra3,"gr")
plot_hyPalette(sp, "gr")
#> Warning: Function 'chk.hy' is deprecated. 
#> Use function 'assert_hyperSpec' instead.


#-----------------------------------------------------
# Example 2
plot_hyPalette(by = "RED color", palette = "#ee0000")


#-----------------------------------------------------
# Example 3
# Use data 'sp' from example 1
# The legend does not make sense in this context. It's just an example.

plot(flu)
plot_hyPalette(sp, "gr", as.legend = TRUE, cex = 1)
#> Warning: Function 'chk.hy' is deprecated. 
#> Use function 'assert_hyperSpec' instead.