Skip to content

default xlim and ylim in qplot are not supportd when non missing #4027

Closed

Description

@moodymudskipper

See below. I think it's against the principles laid out in the tidyverse principle book, it can be fixed by using c(NA_real_, NA_real_) as a default.

The issue arose as I was writing a wrapper around qplot and it choked when passing the parameters xlim = xlim, ylim = ylim.

library(ggplot2)

# works
qplot(Sepal.Width, Sepal.Length, data = iris)

# doesn't work
qplot(Sepal.Width, Sepal.Length, data = iris, xlim = c(NA,NA))
#> Error in UseMethod("limits"): no applicable method for 'limits' applied to an object of class "logical"

# works
qplot(Sepal.Width, Sepal.Length, data = iris, xlim = c(NA_real_,NA_real_))

Created on 2020-05-25 by the reprex package (v0.3.0)

Activity

  1. clauswilke commented on May 25, 2020

    @clauswilke
    Member

    You are correct, though we tend to discourage use of qplot() as much as possible. In any case, feel free to create a PR to fix this.

  2. added this to the ggplot2 3.3.4 milestone on Mar 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugan unexpected problem or unintended behaviorscales 🐍

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions