numbers2colors: Color representation for a numeric variable

View source: R/Functions.R

numbers2colorsR Documentation

Color representation for a numeric variable


The function creates a color represenation for the given numeric input.


   signed = NULL, 
   centered = signed, 
   lim = NULL, 
   commonLim = FALSE,
   colors = if (signed) blueWhiteRed(100) else blueWhiteRed(100)[51:100],
   naColor = "grey")



a vector or matrix of numbers. Missing values are allowed and will be assigned the color given in naColor. If a matrix, each column of the matrix is processed separately and the return value will be a matrix of colors.


logical: should x be considered signed? If TRUE, the default setting is to use to use a palette that starts with green for the most negative values, continues with white for values around zero and turns red for positive values. If FALSE, the default palette ranges from white for minimum values to red for maximum values. If not given, the behaviour is controlled by values in x: if there are both positive and negative values, signed will be considered TRUE, otherwise FALSE.


logical. If TRUE and signed==TRUE, numeric value zero will correspond to the middle of the color palette. If FALSE or signed==FALSE, the middle of the color palette will correspond to the average of the minimum and maximum value. If neither signed nor centered are given, centered will follow signed (see above).


optional specification of limits, that is numeric values that should correspond to the first and last entry of colors.


logical: should limits be calculated separately for each column of x, or should the limits be the same for all columns? Only applies if lim is NULL.


color palette to represent the given numbers.


color to represent missing values in x.


Each column of x is processed individually, meaning that the color palette is adjusted individually for each column of x.


A vector or matrix (of the same dimensions as x) of colors.


Peter Langfelder

See Also

labels2colors for color coding of ordinal labels.

WGCNA documentation built on Jan. 22, 2023, 1:34 a.m.

Related to numbers2colors in WGCNA...