vincentarelbundock · GitHub

Default is 0 (no dodge) and can be set to a positive number to dodge overlapping lineranges or errorbars. The dodging amount is a proportion of the width between notches on the x axis (since x is treated as sequential factor/integer positions).

library(tinyplot)
models <- list(
  "Model A" = lm(mpg ~ wt + cyl, data = mtcars),
  "Model B" = lm(mpg ~ wt + hp + cyl, data = mtcars),
  "Model C" = lm(mpg ~ wt, data = mtcars)
)
results = lapply(names(models), function(m) {
  data.frame(
    model = m,
    term = names(coef(models[[m]])),
    estimate = coef(models[[m]]),
    setNames(data.frame(confint(models[[m]])), c("conf.low", "conf.high"))
  )
})
results = do.call(rbind, results)
tinyplot(estimate ~ term | model,
  ymin = conf.low, ymax = conf.high,
  flip = TRUE, data = results,
  type = type_pointrange(dodge = 0.1))
tinyplot(estimate ~ term | model,
  ymin = conf.low, ymax = conf.high,
  flip = TRUE, data = results[results$model %in% c("Model A", "Model B"), ],
  type = type_errorbar(dodge = 0.4))

Read the original on github.com ↗