Skip to content

Some custom theme elements aren't being reset #477

Closed

Description

@grantmcdermott

Playing around with this a bit, I came across an issue that might be related but maybe it needs to go into a separate issue. I tried:

tinyplot(dist ~ speed, data = cars)

tinytheme("clean2", pch = 17, cex = 3)
tinyplot(dist ~ speed, data = cars)

tinytheme()
tinyplot(dist ~ speed, data = cars)

First, I was surprised that cex = 3 appears to be expanded to various elements (main, axis, x/ylab) which isn't obvious to me from the documentation.

Second, and probably more importantly, I was surprised that reverting to the default theme does not unset this. Shouldn't the third panel look like the first panel?

Originally posted by @zeileis in #442

Looks like this is limited to custom elements that aren't explicitly named in the default params list here.

tinyplot/R/tinytheme.R

Lines 177 to 221 in 8d331f3

theme_default = list(
tinytheme = "default",
adj = par("adj"), # 0.5,
adj.main = par("adj"), # 0.5,
adj.sub = par("adj"), # 0.5,
bg = "white", # par("bg") # "white"
bty = par("bty"), #"o",
cex.axis = par("cex.axis"), #1,
cex.main = par("cex.main"), #1.2,
cex.xlab = par("cex.axis"), #1,
cex.ylab = par("cex.axis"), #1,
col.axis = par("col.axis"), #1,
col.xaxs = par("col.axis"), #1,
col.yaxs = par("col.axis"), #1,
col.lab = par("col.lab"), #"black",
col.main = par("col.main"), #"black",
col.sub = par("col.sub"), #"black",
dynmar = FALSE,
facet.bg = NULL,
facet.border = NA,
family = par("family"), # ""
fg = par("fg"),
font = par("font"), # 1,
font.axis = par("font.axis"), # 1,
font.lab = par("font.lab"), # 1,
font.main = par("font.main"), # 2,
font.sub = par("font.sub"), # 2,
grid = FALSE,
grid.col = "lightgray",
grid.lty = "dotted",
grid.lwd = 1,
lab = par("lab"), # c(5, 5, 7),
las = par("las"), # 0,
lwd = par("lwd"), # 1,
lwd.axis = par("lwd"), # 1,
mar = c(5.1, 4.1, 4.1, 2.1), ## test
mgp = par("mgp"),
# palette.qualitative = "R4",
# palette.sequential = "Viridis",
pch = par("pch"), # 1,
side.sub = 1,
tck = NA,
xaxt = "standard",
yaxt = "standard"
)

Activity

  1. zeileis commented on Sep 17, 2025

    @zeileis
    Collaborator

    I came across the following problem which seems to be related but it is not yet fixed by your previous commit. If I apply the following plot several times on the same device, the margins keep growing from plot to plot:

    library("tinyplot")
    
    tinyplot(bill_len ~ bill_dep, facet = ~ island, data = penguins)
    tinyplot_add(type = "p")
    
    tinyplot(bill_len ~ bill_dep, facet = ~ island, data = penguins)
    tinyplot_add(type = "p")
    
    tinyplot(bill_len ~ bill_dep, facet = ~ island, data = penguins)
    tinyplot_add(type = "p")
    
    Image Image Image
  2. grantmcdermott commented on Sep 17, 2025

    @grantmcdermott
    OwnerAuthor

    Ugh, thanks for the catch. I'll try to take a look tomorrow.

  3. grantmcdermott commented on Sep 17, 2025

    @grantmcdermott
    OwnerAuthor

    Ugh, thanks for the catch. I'll try to take a look tomorrow.

    Closing again and moving to a separate issue, because I think this regression is unrelated.

  4. zeileis commented on Sep 17, 2025

    @zeileis
    Collaborator

    OK, thanks for checking and opening the new issue!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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