Skip to content

tinyplot.<easystats> method improvements #585

@grantmcdermott

Description

@grantmcdermott

Hi modelbased team.

We just released tinyplot v0.6.0. This release includes a variety of internal updates that should, in turn, facilitate improvements to the tinyplot.<eaststats> methods here, including:

  • easier passing of custom legend titles
  • consistent alignment of "dodged" plot layers (e.g., adding joining lines on top of dodged error bars)
  • etc.

I plan to submit a PR with some suggested changes. This issue is mostly for housekeeping/record purposes.

However, I also wanted to flag one issue in particular...

Default theme behaviour

Per the current tinyplot.estimate_means documentation:

theme
A character string specifying the theme to use for the plot. Defaults to "tufte". For other options please see tinyplot::tinytheme(). Use NULL if no theme should be applied.

As the main tinyplot developer, I would say that this is a big no-no for two reasons.

First, the "tufte" theme isn't "dynamic" (in contrast to some other tinyplot themes like "clean", "classic", "minimal", etc.). Specifically, the "tufte" theme doesn't give horizontal labels or respond to white space adjustment. This matters mostly for flipped plot types, which seem to be frequently used in the easystats visualization guides. Compare these two plots (one of the coefficient categories along the y-axis in the first/default plot is completely missing because of the vertical labeling):

library(modelbased)
data(efc, package = "modelbased")
efc <- datawizard::to_factor(efc, c("e16sex", "c172code", "e42dep"))
m <- lm(neg_c_7 ~ e16sex + c172code + barthtot, data = efc)
em <- estimate_means(m, "c172code")
tinyplot::plt(em, flip = TRUE)

tinyplot::plt(em, flip = TRUE, theme = "classic")

Created on 2025-11-27 with reprex v2.1.1

Second, and more importantly, the current implementation doesn't reset the plot theme... which means that this theming behaviour will persist for any base graphics plot afterwards; effectively hijacking the users device settings. I'm actually surprised that CRAN didn't complain about this, but perhaps that's because you wrap your Examples in /donttest?

tinyplot::plt(em)

plot(1:10) ## theme is still on!

Created on 2025-11-27 with reprex v2.1.1

As it happens, tinyplot (since v0.5.0) now provides a method for ephemeral (rather than persistent) themes. I'll include this as part of my PR and also switch to a different default theme (not "tufte"), given the first issue above.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions