plot_setup: Setup a plot

View source: R/plot_setup.R

plot_setupR Documentation

Setup a plot

Description

Sets up a plot based on variables in a dataset. The intended use is for chained/piped commands. Returns the same dataset that was passed in.

Usage

plot_setup(
  d,
  f,
  xlim = NULL,
  ylim = NULL,
  log = "",
  asp = NA,
  xaxs = "r",
  yaxs = "r",
  ...
)

Arguments

d

A data.frame.

f

Optional. A formula y ~ x. The limits of the plot region is calculated from the range of y and x.

xlim

Optional. A 2 element vector, the limits of the x axis.

ylim

Optional. A 2 element vector, the limits of the y axis.

log, asp, xaxs, yaxs

Optional. Options sent in the plot.window command

...

Optional. Options sent to the par command

Examples

iris %>% 
  plot_setup(Sepal.Length~Sepal.Width) %>% 
  split(.$Species) %>% 
  lwith({
    l1 <- lm(Sepal.Length~Sepal.Width)
    lines(Sepal.Width, predict(l1))
  })
  

thomasgstewart/tgsify documentation built on Oct. 26, 2024, 8:15 p.m.