draw_legend.RdFunction to add a legend to an existing plot.
draw_legend(x, y, legend, bty = "n", xpd = NA, adj = c(0, 1.2), ...)The lower and upper boundaries for the x-axis.
The lower and upper boundaries for the y-axis.
A character vector, the text for the legend (see graphics::legend).
A character string, either "o" or
"n" (the default), the type of box to
draw around the legend (see graphics::legend).
A logical value or NA, determining
how the legend should be clipped relative to the
figure region (see graphics::par). Defaults to NA.
A numeric vector of two values, the relative x and y-axis position of the legend, where values are ratios (e.g., values of 1 will place the legend exactly at the top right corner of the figure boundary).
Additional arguments to pass to graphics::legend.
Adds a legend to an existing plot.
# Example figure
x <- 0:1; y <- 0:1
plot_blank(x, y)
# Add legend in middle of figure
draw_legend(
x, y, 'Example',
adj = c( .5, .5 )
)