Skip to content

Commit

Permalink
Fixed a bug when combining counts with axis limits (#41).
Browse files Browse the repository at this point in the history
  • Loading branch information
jbengler committed Jan 7, 2025
1 parent 129c515 commit 0de99ed
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* New color scheme `colors_discrete_rainbow` (@electrolars, #35).
* The function `save_plot()` gains the new argument `view_plot`
to control whether to view the plot on screen after saving (#40).
* Fixed a bug when combining counts with axis limits (#41).

# tidyplots 0.2.0

Expand Down
9 changes: 4 additions & 5 deletions R/adjust.R
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,10 @@ ff_adjust_axis <- function(axis) {
}
})

# Set limits
if (!is.null(plot$tidyplot$limits_x) && is_continuous(plot, "x")) xlim <- plot$tidyplot$limits_x else xlim <- NULL
if (!is.null(plot$tidyplot$limits_y) && is_continuous(plot, "y")) ylim <- plot$tidyplot$limits_y else ylim <- NULL
if (!is.null(xlim) || !is.null(ylim))
suppressMessages(plot <- plot + ggplot2::coord_cartesian(xlim = xlim, ylim = ylim))
# Set limits via coord_cartesian
if (!is.null(plot$tidyplot$limits_x) || !is.null(plot$tidyplot$limits_y)) {
suppressMessages(plot <- plot + ggplot2::coord_cartesian(xlim = plot$tidyplot$limits_x, ylim = plot$tidyplot$limits_y))
}
return(plot)
}

Expand Down

0 comments on commit 0de99ed

Please sign in to comment.