add_lines: Add lines with labels to pre-existing ggplot

Description Usage Arguments Examples

View source: R/add_lines.R

Description

Add lines with labels to pre-existing ggplot

Usage

1
2
add_lines(p, df, xpos = 0.3, add.coord.fixed = TRUE, lty = NULL,
  color = NULL, size = 0.5, add_theme_bw2 = TRUE, ...)

Arguments

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

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
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()

predict3d documentation built on Sept. 3, 2019, 5:06 p.m.