-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Labels
messagesrequests for improvements to error, warning, or feedback messagesrequests for improvements to error, warning, or feedback messages
Description
Hi,
I found a problem with geom_tile()
when using free facets and external data.
The original goal is probably irrelevant, but it was to set the limit in one facet only so that free axes are aligned.
Here, using geom_tile()
produces multiple warnings: Warning in min(x): no non-missing arguments to min; returning Inf
.
This was not the case before the recent major update.
Here is the code to reproduce the bug.
The natural alternative was to use geom_blank()
, but as you can see, it introduces an unexpected little shift on the X axis.
library(tidyverse)
df = tibble(subjid=1:90, group=cut(subjid, c(0,50,100)))
dummy = tibble(subjid=100, group="(50,100]")
p = ggplot(df, aes(x = subjid, y = "Y")) +
geom_tile(color = "black") +
facet_wrap(~group, ncol=1, scales="free_x")
#The original output, with unequal ranges of 50 and 40
p
#The expected output, with equal ranges of 50, but unexpected warnings since version 4.0
p +
geom_tile(data = dummy, fill = NA)
#> Warning in min(x): no non-missing arguments to min; returning Inf
#> Warning in max(x): no non-missing arguments to max; returning -Inf
#> Warning in min(d[d > tolerance]): no non-missing arguments to min; returning
#> Inf
#> Warning in min(x): no non-missing arguments to min; returning Inf
#> Warning in max(x): no non-missing arguments to max; returning -Inf
#The alternative, but with a little shift on the X axis (tick 100 is not perfectly aligned with tick 50 like with geom_tile)
p +
geom_blank(data = dummy)
Created on 2025-10-12 with reprex v2.1.1
Metadata
Metadata
Assignees
Labels
messagesrequests for improvements to error, warning, or feedback messagesrequests for improvements to error, warning, or feedback messages