Skip to content

infelicity when calling lattice::panel.grid #46

@tyner

Description

@tyner

Reprex:

dat <- data.frame(x = structure(19951, class = "Date"),
                  y = c(109237907428.42064, 109237907428.42065)
                  )

p <- lattice::xyplot(y ~ x,
                     data = dat,
                     panel = function(x,y,...) {
                        lattice::panel.grid(h = -5,
                                            v = 0,
                                            col = "lightgray"
                                            )
                        lattice::panel.xyplot(x, y, ...)
                     }
                     )
                     
print(p, panel.error = NULL)

The root cause of the problem appears to be inside lattice::panel.grid where it does this (slightly paraphrased to avoid method dispatch)

limits <- current.panel.limits()
scale <- limits$ylim
at <- lattice:::formattedTicksAndLabels.default(scale, n = 5L)$at
at <- at[at > min(scale) & at < max(scale)]

at which point at has length zero, which gets passed to grid::grid.segments which then passes it to grid::segmentsGrob which then passes it to grid::unit which throws the error.

I am not sure whether there is a foolproof way to deal with such conditions gracefully, but thank you for considering nonetheless.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions