Skip to content
Permalink
Browse files
Fix issue with double label/breaks of gg_season()
  • Loading branch information
mitchelloharawild committed Nov 16, 2020
1 parent 1545e77 commit f7894e859fe0258122011ce5148282b121b0c0d1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
@@ -289,7 +289,7 @@ gg_season <- function(data, y = NULL, period = NULL, facet_period = NULL,
} else{
ggplot2::scale_x_date()$trans$breaks(limit)
}
unique(time_offset_origin(breaks, period))
unique(time_offset_origin(within_bounds(breaks, limit), period))
}, labels = within_time_identifier)
} else if(inherits(data[[idx]], "POSIXct")){
p <- p + ggplot2::scale_x_datetime(breaks = function(limit){
@@ -299,7 +299,7 @@ gg_season <- function(data, y = NULL, period = NULL, facet_period = NULL,
else{
ggplot2::scale_x_datetime()$trans$breaks(limit)
}
unique(time_offset_origin(breaks, period))
unique(time_offset_origin(within_bounds(breaks, limit), period))
}, labels = within_time_identifier)
} else {
scale_fn <- paste0("scale_x_", ggplot2::scale_type(data[[idx]]))
@@ -315,7 +315,7 @@ gg_season <- function(data, y = NULL, period = NULL, facet_period = NULL,
} else{
scale_fn()$trans$breaks(limit)
}
unique(time_offset_origin(breaks, period))
unique(time_offset_origin(within_bounds(breaks, limit), period))
}, labels = within_time_identifier)
}

@@ -201,3 +201,7 @@ time_offset_origin <- function(x, period, origin = time_origin(x)){
}
else origin + (x - x_start)
}

within_bounds <- function(x, lim) {
x[x>=lim[1] & x<=lim[2]]
}

0 comments on commit f7894e8

Please sign in to comment.