assignColVar {GCDkit}R Documentation

Colours by a variable

Description

Assigns plotting colours according to the values of the variable.

Usage

assignColVar(what=NULL,pal="heat.colours",save=TRUE,n=15,range=NULL,
    quant=0,eq.classes=FALSE,alt.leg=FALSE)

Arguments

what

variable name or a formula; if NULL a dialogue is displayed

pal

character; name of a palette

save

logical;should the newly picked colours be assigned to 'labels'?

n

desired approximate number of colours to be assigned.

range

numeric vector with two items; (optional) desired range of the variable to be covered.

quant

numeric, 0-50; quantile to be potentially used to get rid of outliers. See details.

eq.classes

logical; should classes contain equal number of values?

alt.leg

logical; should be the alternative (continuous) legend shown? See Examples.

Details

For selection of the variable is employed the function 'selectColumnLabel'. The user can specify either existing data column in the 'WR' or a formula. The colours can be optionally (default behaviour) assigned globally, so that all the plots will use these from this point on. If not specified upon function call, the palette is picked using selectPalette. The possible values are: 'grays','reds','blues','greens','cyans','violets','yellows','cm.colors',
'heat.colors', 'terrain.colors','topo.colors', 'rainbow' and 'jet.colors'.

Also, user-defined palette functions are supported. See Examples.

The analyses with no data available for the colours assignment will remain black.

If quant differs from the default value of zero, the data are trimmed to an interval (quant, 100-quant)-th quantile of the dataset and all values out of it plotted in gray.

Setting eq.classes=TRUE allows to have classes with equal number of values (as opposed to equal intervals). This option is best suited for very skewed datasets (lots of points with similar values, some outliers).

Value

A list of two components, col and leg. The former are the plotting colours, the latter contains information needed to build a legend. If save = TRUE, 'labels$Colour' will acquire the codes of desired plotting colours.

Author(s)

Vojtěch Janoušek, vojtech.janousek@geology.cz

Jean-François Moyen, jfmoyen@gmail.com

See Also

quantile Colours by a single variable can be assigned by assignColLab, symbols and colours by groups simultaneously by assignSymbGroup. Uniform colours are obtained by assign1col. Table of available plotting colours is obtained by showColours.

Examples

    data(atacazo)
    accessVar("atacazo")
    
    assignColVar("Na2O/K2O","greens")
    plotDiagram("PeceTaylor",FALSE,FALSE)
    
    my.palette<-colorRampPalette(c("black", "darkgreen", "red"),space = "rgb")
    assignColVar("SiO2","my.palette")
    plotDiagram("PeceTaylor",FALSE,FALSE)
    
    assignColVar("SiO2","my.palette",n=7,quant=5)
    plotDiagram("PeceTaylor",FALSE,FALSE)
    showLegend()
    showLegend(alt.leg=TRUE)

[Package GCDkit version 6.1 Index]