Skip to content

Using scale_fill_continuous(breaks=NULL) results in error #579

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
wch opened this issue Jun 14, 2012 · 8 comments
Closed

Using scale_fill_continuous(breaks=NULL) results in error #579

wch opened this issue Jun 14, 2012 · 8 comments
Milestone

Comments

@wch
Copy link
Member

wch commented Jun 14, 2012

Some of the visual tests in visual_test/scale-breaks.r now throw errors. This was introduced by e6594a1, where the colorbar guide started being used as the default.

Here are the two bad tests:

dat <- data.frame(x=1:3, y=1:3)

ggplot(dat, aes(x=1, y=y, fill=x)) + geom_point(shape=21) + scale_fill_continuous(breaks=NULL)

ggplot(dat, aes(x=1, y=y, colour=x)) + geom_point() + scale_colour_continuous(breaks=NULL)

We should also have some unit tests for this...

@kohske
Copy link
Collaborator

kohske commented Jun 14, 2012

0.9.1 also results in error.
And legend guide also induce a warning.
What is the expected behavior if breaks = NULL for non-positional scales?

@wch
Copy link
Member Author

wch commented Jun 14, 2012

The error in master (1df1e82) is this:

dat <- data.frame(x=1:3, y=1:3)
ggplot(dat, aes(x=1, y=y, fill=x)) + geom_point(shape=21) + scale_fill_continuous(breaks=NULL)
# Error in names(guide$key) <- c(output, ".label", ".value") : 
#   'names' attribute [3] must be the same length as the vector [2]

ggplot(dat, aes(x=1, y=y, colour=x)) + geom_point() + scale_colour_continuous(breaks=NULL)
# Error in names(guide$key) <- c(output, ".label", ".value") : 
#  'names' attribute [3] must be the same length as the vector [2]

Also, this gives a warning:

ggplot(dat, aes(x=1, y=y, size=x)) + geom_point() + scale_size_continuous(breaks=NULL)
# Warning message:
# In is.na(breaks) : is.na() applied to non-(list or vector) of type 'NULL'

@kohske
Copy link
Collaborator

kohske commented Jun 14, 2012

I mean that these errors and warnings also happen in the released version 0.9.1.

I'm sure why this error happens.
But I'm not sure how it should be. The breaks = NULL for non-positional scales would be meaningless.

Should it be simply ignored, with some warning message?

@wch
Copy link
Member Author

wch commented Jun 14, 2012

In 0.9.1, I get warnings only, but no errors.

ggplot(dat, aes(x=1, y=y, colour=x)) + geom_point() + scale_colour_continuous(breaks=NULL)
# Warning message:
# In is.na(breaks) : is.na() applied to non-(list or vector) of type 'NULL'

Maybe it should not show the legend when breaks=NULL? I think that is the existing behavior in 0.9.1.

@kohske
Copy link
Collaborator

kohske commented Jun 14, 2012

@wch

yes, but in 0.9.1,

> ggplot(dat, aes(x=1, y=y, colour=x)) + geom_point() + scale_colour_continuous(breaks=NULL, guide = "colorbar")
Error in names(guide$key) <- c(output, ".label", ".value") : 
  'names' attribute [3] must be the same length as the vector [2]

So the bug(?) is not due to changing the colorbar as default.

Maybe it should not show the legend when breaks=NULL?

I agree. Do you think there is a situation where someone want to show colorbar without tick/lables?

@kohske
Copy link
Collaborator

kohske commented Jun 14, 2012

So possible solution for break = NULL for the non-positional scale is either,

  1. Surpress showing guide, with some warning messages.
  2. Use default breaks (waiver()) instead, with some warning messages.

The warning message should be like:

breaks = NULL for non-spatial scale is meaningless so the guide is not displayed.

@wch
Copy link
Member Author

wch commented Jun 14, 2012

Oh, I see what you mean. Yes, the bug is in colorbar.

@kohske kohske closed this as completed in d4fc00c Jun 27, 2012
@kohske
Copy link
Collaborator

kohske commented Jun 27, 2012

ah..., if the branch referring the issue is merged on github, those who commit the branch will close the issue, I understand.
A bit surprising because I was sleeping at that time...

@lock lock bot locked as resolved and limited conversation to collaborators Jun 20, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants