assign.plot.colors: Assign colors to samples

Description Usage Arguments Details Value Author(s) Examples

View source: R/assign.plot.colors.R

Description

Function that assigns unique colors to each class represented in a corpus: used for graph auto-coloring.

Usage

1
assign.plot.colors(labels, col = "colors", opacity = 1)

Arguments

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).

Details

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.

Value

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, ...).

Author(s)

Maciej Eder

Examples

1
2
3
4
5
6
7
8
9
# 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")

Example output

### stylo version: 0.6.9 ###

If you plan to cite this software (please do!), use the following reference:
    Eder, M., Rybicki, J. and Kestemont, M. (2016). Stylometry with R:
    a package for computational text analysis. R Journal 8(1): 107-121.
    <https://journal.r-project.org/archive/2016/RJ-2016-007/index.html>

To get full BibTeX entry, type: citation("stylo")
Warning message:
no DISPLAY variable so Tk is not available 
       Tacitus_Annales       Tacitus_Germania      Tacitus_Histories 
                 "red"                  "red"                  "red" 
     Caesar_Civil_wars     Caesar_Gallic_wars Livius_Ab_Urbe_Condita 
               "green"                "green"                 "blue" 
       Tacitus_Annales       Tacitus_Germania      Tacitus_Histories 
           "#000000FF"            "#000000FF"            "#000000FF" 
     Caesar_Civil_wars     Caesar_Gallic_wars Livius_Ab_Urbe_Condita 
           "#595959FF"            "#595959FF"            "#B3B3B3FF" 

stylo documentation built on Dec. 6, 2020, 5:06 p.m.