-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Closed
Description
Hi, if my x-aesthetic is a date, annotate_custom
generates conversion warnings when I use the defaults for xmin
and xmax
(which are numeric: -Inf
).
ggplot(economics, aes(x = date, y = unemploy)) +
geom_line() +
annotation_custom(grid::textGrob("DRAFT"))
yields
Warning messages:
1: In scale_x_date() :
A <numeric> value was passed to a Date scale.
ℹ The value was converted to a <Date> object.
2: In scale_x_date() :
A <numeric> value was passed to a Date scale.
ℹ The value was converted to a <Date> object.
And a perfectly good plot.
The workaround for the warnings is to specify that xmin and xmax are dates explicitly. e.g.
ggplot(economics, aes(x = date, y = unemploy)) +
geom_line() +
annotation_custom(grid::textGrob("DRAFT"), xmin = as.Date(-Inf), xmax = as.Date(Inf))
Would it be possible to have the defaults match the class of these arguments to to the class of the x aesthetic?
Metadata
Metadata
Assignees
Labels
No labels