Skip to content

Allow setting one of the limits of scale #684

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from

Conversation

jimhester
Copy link
Contributor

Implements setting of only one limit of a continuous scale by specifying
NA for the limit which you don't want to set. See #557.

I had to use NA instead of NULL to implement this, as is.null() is not
vectorized, a vector with null at any location is TRUE.

Implements setting of only one limit of a continuous scale by specifying
NA for the limit which you don't want to set.
@wch
Copy link
Member

wch commented Oct 10, 2012

Nice, this is a useful feature. I've made some comments on the code.

@@ -52,7 +52,7 @@ ylim <- function(...) {
limits <- function(lims, var) UseMethod("limits")
limits.numeric <- function(lims, var) {
stopifnot(length(lims) == 2)
if (lims[1] > lims[2]) {
if (sum(is.na(lims)) == 0 &lims[1] > lims[2]) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a bit cleaner IMO, and the && is more appropriate:

if (all(!is.na(lims)) && lims[1] > lims[2])

(edited this to use all instead of any)

@jimhester
Copy link
Contributor Author

I agree with all of your comments, the new commit should fix them. Also thanks for pointing out the any function, I was not aware of it, and it makes the code much clearer, I always thought the sum(logicals) idiom seemed hacky. Thanks for the comments!

@jimhester
Copy link
Contributor Author

Is there anything else you need from this pull request in order to merge it? I would be happy to make any changes needed.

@wch
Copy link
Member

wch commented Dec 28, 2012

Hi Jim - at the moment I'm working on other projects besides ggplot2, but when I get back to it I'll be able to take a closer look at the pull request. Offhand it looks fine, but merging changes like this requires some careful consideration to make sure it that it's done right, and also that it doesn't introduce subtle bugs.

@hadley
Copy link
Member

hadley commented Feb 24, 2014

Could you please rebase/merge against master, re-document with the development version of roxygen2 (install_github("klutometis/roxygen) and resubmit?

@hadley hadley closed this Feb 24, 2014
@jimhester jimhester mentioned this pull request Feb 24, 2014
@lock
Copy link

lock bot commented Jan 19, 2019

This old issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with reprex) and link to this issue. https://reprex.tidyverse.org/

@lock lock bot locked and limited conversation to collaborators Jan 19, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants