View source: R/plots-palettes.R
getShapePalette | R Documentation |
Get a shape palette of specified length, either from a vector of names for the palette, or from a specified length.
getShapePalette( n = NULL, x = NULL, includeNA = FALSE, asText = FALSE, palette = if (asText) { clinShapesText } else { clinShapes } )
n |
Integer of length 1, number of elements in palette. |
x |
Vector with elements used for palette.
If factor, the levels are used, otherwise the unique elements of the vector.
Missing values are automatically removed, excepted if
|
includeNA |
Logical (FALSE by default),
should NA elements be retained in the palette in case
|
asText |
Logical (FALSE by default), should the palette be expressed as integer (base R plot and ggplot2 compatible) or in text format (e.g. required if combined with unicode symbols in ggplot2)? |
palette |
A vector of custom shapes,
or a function returning this vector from a specific
number of shapes. |
Note that 19 unique symbols are available at maximum (replicated if necessary).
Vector of shapes,
named with the elements in x
if x
is specified.
Laure Cougnaud and Michela Pasetto
#' extract longest shape palette available getShapePalette(n = 19) # extract palette for a vector getShapePalette(x = paste('treatment', 1:4)) # include missing getShapePalette(x = c(NA_character_, "group1"), includeNA = TRUE) getShapePalette(x = c(NA_character_, "group1"), includeNA = FALSE) # change default settings getShapePalette(x = paste('treatment', 1:3), palette = c("circle", "triangle")) # get symbols as 'text' (e.g. to be combined with Unicode in ggplot2) getShapePalette(x = paste('treatment', 1:4), asText = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.