r-lib / scales

Tools for ggplot2 scales
https://scales.r-lib.org
Other
395 stars 107 forks source link

Label formatting in `transform_time()` with zero-width limits #446

Open teunbrand opened 1 month ago

teunbrand commented 1 month ago

This isssue is a port from https://github.com/tidyverse/ggplot2/issues/3475.

When you provide zero-width limits to transform_time(), the formatting of the labels does not resemble typical time formatting.

limits <- lubridate::as_datetime("2010-08-03 00:50:50")
limits <- c(limits, limits)

trans <- scales::transform_time()
breaks <- trans$breaks(limits)
labels <- trans$format(breaks)
labels
#> [1] "47" "48" "49" "50" "51" "52"

Created on 2024-08-06 with reprex v2.1.1