grantmcdermott / tinyplot

Lightweight extension of the base R graphics system
https://grantmcdermott.com/tinyplot
Apache License 2.0
211 stars 7 forks source link

Automatic ribbon order #54

Closed grantmcdermott closed 11 months ago

grantmcdermott commented 11 months ago

Fixes #53 .

devtools::load_all("~/Documents/Projects/plot2")
#> ℹ Loading plot2

mod = lm(mpg ~ wt, mtcars)
pred = predict(mod, interval = "confidence")

mtcars2 = cbind(mtcars, pred)

with(
  mtcars2,
  plot2(
    x = wt, y = fit,
    ymin = lwr, ymax = upr,
    type = "ribbon"
  )
)

This PR also allows interval plot types (ribbon, pointrange, etc) to be specified without a yvar.


with(
  mtcars2,
  plot2(
    x = wt, 
    ymin = lwr, ymax = upr,
    type = "ribbon"
  )
)