add_lines | R Documentation |
Add lines with labels to pre-existing ggplot
add_lines(
p,
df,
xpos = 0.3,
add.coord.fixed = TRUE,
lty = NULL,
color = NULL,
size = 0.5,
add_theme_bw2 = TRUE,
...
)
p |
An object of class ggplot |
df |
A data.frame. Required columns are slope, intercept and label |
xpos |
A numeric. Relative horizontal position |
add.coord.fixed |
Logical. Whether or not add coord_fixed() function |
lty |
line type |
color |
line color |
size |
line size |
add_theme_bw2 |
logical Whether or not add theme_bw2() |
... |
Further arguments to be passed to geom_text |
require(ggplot2)
fit=lm(mpg~wt*hp,data=mtcars)
df=calEquation(fit)
p=ggplot(data=mtcars,aes(x=wt,y=mpg))
add_lines(p,df)
add_lines(p,df,lty=1:3,color=1:3,size=1)
fit=lm(mpg~wt*vs,data=mtcars)
df=calEquation(fit)
p=ggplot(data=mtcars)+geom_point(aes(x=wt,y=mpg))
add_lines(p,df)
add_lines(p,df,lty=1:2,color=1:2,size=1)+theme_bw()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.