add_line | R Documentation |
Add a line to a ggplot
add_line(data, y)
data |
A data frame |
y |
The name of the variable to plot as a line (as a string) |
This function maps variable y
to the y
aesthetic of a
geom_line
and adds it to a preexisting ggplot.
y
cannot be "y".
data <- tibble::tibble(x = 1:3, z = 3:1) ggplot2::ggplot(data, ggplot2::aes(x = x, y = x)) + ggplot2::geom_line() + add_line(data, "z")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.