draw_legend | R Documentation |
Function to add a legend to an existing plot.
draw_legend(x, y, legend, bty = "n", xpd = NA, adj = c(0, 1.2), ...)
x |
The lower and upper boundaries for the x-axis. |
y |
The lower and upper boundaries for the y-axis. |
legend |
A character vector, the text for the legend (see graphics::legend). |
bty |
A character string, either |
xpd |
A logical value or |
adj |
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 )
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.