Skip to content

Commit

Permalink
Forcing ymin to start at 0 when distribution plot #258
Browse files Browse the repository at this point in the history
  • Loading branch information
kassambara committed May 8, 2020
1 parent 6e1d483 commit 4105c55
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion R/utilities.R
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit 4105c55

Please sign in to comment.