a b/man/drawLegends.Rd
1
% Generated by roxygen2: do not edit by hand
2
% Please edit documentation in R/EnrichCirclize.R
3
\name{drawLegends}
4
\alias{drawLegends}
5
\title{Draw Dual-Sided Legends on a Plot}
6
\usage{
7
drawLegends(
8
  labels,
9
  colors,
10
  legend_width,
11
  x_positions,
12
  y_position,
13
  just_positions,
14
  text_alignments,
15
  font_size
16
)
17
}
18
\arguments{
19
\item{labels}{Vector of labels for the legends.}
20
21
\item{colors}{Vector of colors corresponding to the labels.}
22
23
\item{legend_width}{The width of each legend viewport expressed in grid units.}
24
25
\item{x_positions}{Numeric vector of length 2 specifying the x-positions of the left and right legends.}
26
27
\item{y_position}{The y-position common for both legends, expressed as a fraction of the plot height.}
28
29
\item{just_positions}{List of two vectors, each specifying the horizontal and vertical justification for the legends.}
30
31
\item{text_alignments}{List of two character strings specifying text alignments for the legends ('left' or 'right').}
32
33
\item{font_size}{Numeric value specifying the font size for the legend labels.}
34
}
35
\value{
36
Invisible. This function is called for its side effects of drawing legends on a plot.
37
}
38
\description{
39
This function creates two sets of legends, one on the left and one on the right side of a plot.
40
It displays color-coded legends with labels corresponding to different data categories.
41
Each legend entry consists of a colored rectangle and a text label. The left side legend has
42
text aligned to the right of the color block, while the right side legend has text aligned
43
to the left of the color block.
44
}
45
\examples{
46
labels <- c("Label1", "Label2", "Label3", "Label4", "Label5", "Label6")
47
colors <- c("#ff0000", "#00ff00", "#0000ff", "#ffff00", "#ff00ff", "#00ffff")
48
49
# Convert to 'unit' objects for grid
50
grid::grid.roundrect(
51
  x = grid::unit(0.5, "npc"),  # "npc" stands for normalized parent coordinates
52
  y = grid::unit(0.5, "npc"),
53
  width = grid::unit(0.1, "npc"),
54
  height = grid::unit(0.05, "npc"),
55
  gp = grid::gpar(fill = "red"),
56
  r = grid::unit(0.1, "npc")  # rounding radius
57
)
58
59
# Example of drawing legends with specific labels and colors
60
drawLegends(labels, colors, grid::unit(2, "cm"), c(0.225, 0.75), 0.5,
61
            list(c("left", "center"), c("right", "center")),
62
            list("right", "left"), 10)
63
64
}