From 4105c55e4764f6f01b636af34ab8d15e203f40f9 Mon Sep 17 00:00:00 2001 From: Alboukadel Kassambara Date: Fri, 8 May 2020 11:09:27 +0200 Subject: [PATCH] Forcing ymin to start at 0 when distribution plot #258 --- R/utilities.R | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/R/utilities.R b/R/utilities.R index 5c150e33..4e827a05 100644 --- a/R/utilities.R +++ b/R/utilities.R @@ -365,7 +365,12 @@ p .set_ticksby <- function(p, xticks.by = NULL, yticks.by = NULL) { if(!is.null(yticks.by)) { - p <- p + scale_y_continuous(breaks = get_breaks(by = yticks.by)) + # Forcing ymin to start at 0 when distribution plot + gg_mapping <- .get_gg_xy_variables(p) + is_density_plot <- gg_mapping["y"] %in% c("..count..", "..density..", "..ecdf..") + ymin <- NULL + if(is_density_plot) ymin <- 0 + p <- p + scale_y_continuous(breaks = get_breaks(by = yticks.by, from = ymin)) } else if(!is.null(xticks.by)) { p <- p + scale_x_continuous(breaks = get_breaks(by = xticks.by))