From dedf230e888f6eba95f7361cb65a900118f1f561 Mon Sep 17 00:00:00 2001 From: Thomas Lin Pedersen Date: Wed, 14 Apr 2021 12:28:50 +0200 Subject: [PATCH] Only apply limits if they are not NA --- NEWS.md | 3 +++ R/quick-plot.r | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/NEWS.md b/NEWS.md index 60159e47bf..66e06287a9 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,8 @@ # ggplot2 (development version) +* Fix a bug in `qplot()` when supplying `c(NA, NA)` as axis limits + (@thomasp85, #4027) + * Fix bug in `geom_dotplot()` where dots would be positioned wrong with `stackgroups = TRUE` (@thomasp85, #1745) diff --git a/R/quick-plot.r b/R/quick-plot.r index 6870e69387..9e320f6746 100644 --- a/R/quick-plot.r +++ b/R/quick-plot.r @@ -166,8 +166,8 @@ qplot <- function(x, y, ..., data, facets = NULL, margins = FALSE, if (!missing(xlab)) p <- p + xlab(xlab) if (!missing(ylab)) p <- p + ylab(ylab) - if (!missing(xlim)) p <- p + xlim(xlim) - if (!missing(ylim)) p <- p + ylim(ylim) + if (!missing(xlim) && !all(is.na(xlim))) p <- p + xlim(xlim) + if (!missing(ylim) && !all(is.na(ylim))) p <- p + ylim(ylim) p }