View source: R/assign.plot.colors.R
assign.plot.colors | R Documentation |
Function that assigns unique colors to each class represented in a corpus: used for graph auto-coloring.
assign.plot.colors(labels, col = "colors", opacity = 1)
labels |
a vector containing the names of the samples in a corpus; it is obligatory to use an underscore as a class delimiter. Consider the following examples: c("Sterne_Tristram", "Sterne_Sentimental", "Fielding_Tom", ...), where the classes are the authors' names, and c("M_Joyce_Dubliners", "F_Woolf_Night_and_day", "M_Conrad_Lord_Jim", ...), where the classes are M(ale) and F(emale) according to authors' gender. Note that only the part up to the first underscore in the sample's name will be included in the class label. |
col |
an optional argument specifying the color palette to be used: "colors" for full-color output (default), "greyscale" for greyscale (useful for preparing publishable pictures), and "black", if no colors should be used. |
opacity |
optional argument to set transparency/opacity of the colors. 0 means full transparency, 1 means full opacity (default). |
Function for graph auto-coloring; depending on the user's choice it assigns either colors or greyscale tones to matching strings of characters which stand for class identifiers. These metadata will typically be encoded in the texts' filenames. (As class delimiter, the underscore character should be used). Alternatively, all labels can be plotted in black.
The function returns a vector of colors, using their conventional names
(e.g. red
, maroon4
, mediumturquoise
, gold4
,
deepskyblue
, ...), or numeric values if the greyscale option was
chosen (e.g. #000000
, #000000
, #595959
,
#B2B2B2
, ...).
Maciej Eder
# in this example, three discrete classes are specified,
# for Tacitus, Caesar, and Livius
sample.names = c("Tacitus_Annales","Tacitus_Germania","Tacitus_Histories",
"Caesar_Civil_wars","Caesar_Gallic_wars",
"Livius_Ab_Urbe_Condita")
assign.plot.colors(sample.names)
# as above, but using greyscale:
assign.plot.colors(sample.names, col = "greyscale")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.