learn legend paramters as list

learn_legend(lines, sep)

Arguments

lines

a vector of character strings from template file.

sep

a character specifying the separator.

Value

a list of legned parameters containing

title

a character specifying the title of legend. There should not be the character same with separater within.

position_x

a number specifying the x axis px value of the legend.

position_y

a number specifying the y axis px value of the legend.

horizontal

To order legend entries horizontally instead of vertically, set this parameter to 1

shapes

Shape should be a number between 1 and 6, or any protein domain shape definition. 1-square, 2-circle, 3-star, 4-right pointing triangle, 5-left pointing triangle, 6-checkmark

colors

define colors for each legend element (use hexadecimal, RGB or RGBA notation; if using RGB/RGBA, COMMA cannot be used as SEPARATOR)

labels

The legend element label.There should not be the character same with separater within.

shape_scales

For each shape, you can define a scaling factor between 0 and 1.

Examples

tree <- system.file("extdata",
                    "tree_of_itol_templates.tree",
                    package = "itol.toolkit")
df_frequence <- data.table::fread(system.file("extdata",
                                              "templates_frequence.txt",
                                              package = "itol.toolkit"))
## create unit
unit <- create_unit(data = df_frequence,
                    key = "Quickstart",
                    type = "DATASET_SIMPLEBAR",
                    method = "mean",
                    tree = tree)
#> Using the first column as id: templates
#> The input data are mutate as one column by method: mean
## write unit
file <- tempfile()
write_unit(unit,file)
## Learn legend parameters
lines <- line_clean(file=file)
sep = learn_separator(file = file)
learn_legend(lines = lines, sep = sep)
#> $title
#> [1] "Example legend title"
#> 
#> $position_x
#> NULL
#> 
#> $position_y
#> NULL
#> 
#> $horizontal
#> NULL
#> 
#> $shapes
#> [1] "1" "1" "2" "2"
#> 
#> $colors
#> [1] "#ff0000" "#00ff00" "#00ffff" "#0000ff"
#> 
#> $labels
#> [1] "value1" "value2" "value3" "value4"
#> 
#> $shape_scales
#> NULL
#>