Skip to content

scale error when setting aes(colour = NULL) #2688

Closed
@ThierryO

Description

@ThierryO

Originally filed as r-lib/scales#125. File again here as requested by @hadley.

The code below used to work. Now it returns the error Error: Discrete value supplied to continuous scale. Is this a bug or a feature?

ggplot(mtcars, aes(x = wt, y = mpg, colour = factor(cyl), fill = factor(cyl))) +
  geom_smooth(method = "lm", aes(fill = NULL, colour = NULL)) +
  geom_point() +
  geom_smooth(method = "lm")

I know it can write the same plot as below. But the code above is more succinct.

ggplot(mtcars, aes(x = wt, y = mpg)) +
  geom_smooth(method = "lm") +
  geom_point(aes(colour = factor(cyl), fill = factor(cyl))) +
  geom_smooth(method = "lm", aes(colour = factor(cyl), fill = factor(cyl)))
I'm using a development version of `ggplot2` and `scales`
Session info --------------------------------------------------------------------------------------------------
 setting  value                       
 version  R version 3.4.4 (2018-03-15)
 system   x86_64, linux-gnu           
 ui       RStudio (1.1.442)           
 language nl_BE:nl                    
 collate  nl_BE.UTF-8                 
 tz       Europe/Brussels             
 date     2018-06-07                  

Packages ------------------------------------------------------------------------------------------------------
 package      * version    date       source                              
 assertthat     0.2.0      2017-04-11 CRAN (R 3.4.0)                      
 cli            1.0.0      2017-11-05 cran (@1.0.0)                       
 colorspace     1.3-2      2016-12-14 CRAN (R 3.4.0)                      
 crayon         1.3.4      2017-09-16 CRAN (R 3.4.2)                      
 dichromat      2.0-0      2013-01-24 CRAN (R 3.4.0)                      
 digest         0.6.15     2018-02-14 Github (eddelbuettel/digest@d9f40a9)
 ggplot2      * 2.2.1.9000 2018-05-16 Github (hadley/ggplot2@2b0a954)     
 glue           1.2.0      2017-10-29 cran (@1.2.0)                       
 graphics     * 3.4.4      2018-03-16 local                               
 grDevices    * 3.4.4      2018-03-16 local                               
 grid           3.4.4      2018-03-16 local                               
 gtable         0.2.0      2016-02-26 CRAN (R 3.4.0)                      
 labeling       0.3        2014-08-23 CRAN (R 3.4.0)                      
 lattice        0.20-35    2017-03-25 CRAN (R 3.4.1)                      
 lazyeval       0.2.1      2017-10-29 cran (@0.2.1)                       
 magrittr       1.5        2014-11-22 CRAN (R 3.4.0)                      
 MASS           7.3-50     2018-04-30 CRAN (R 3.4.4)                      
 Matrix         1.2-14     2018-04-09 CRAN (R 3.4.4)                      
 methods      * 3.4.4      2018-03-16 local                               
 mgcv           1.8-23     2018-01-15 CRAN (R 3.4.4)                      
 munsell        0.4.3      2016-02-13 CRAN (R 3.4.0)                      
 nlme           3.1-137    2018-04-07 CRAN (R 3.4.4)                      
 pillar         1.2.3      2018-05-25 CRAN (R 3.4.4)                      
 plyr           1.8.4      2016-06-08 CRAN (R 3.4.0)                      
 R6             2.2.2      2017-06-17 CRAN (R 3.4.0)                      
 RColorBrewer   1.1-2      2014-12-07 CRAN (R 3.4.0)                      
 Rcpp           0.12.17    2018-05-18 CRAN (R 3.4.4)                      
 reshape2       1.4.3      2017-12-11 cran (@1.4.3)                       
 rlang          0.2.1      2018-05-30 CRAN (R 3.4.4)                      
 scales         0.5.0.9000 2018-06-05 local                               
 stats        * 3.4.4      2018-03-16 local                               
 stringi        1.2.2      2018-05-02 CRAN (R 3.4.4)                      
 stringr        1.3.1      2018-05-10 CRAN (R 3.4.4)                      
 tibble         1.4.2      2018-01-22 cran (@1.4.2)                       
 tools          3.4.4      2018-03-16 local                               
 utf8           1.1.4      2018-05-24 CRAN (R 3.4.4)                      
 utils        * 3.4.4      2018-03-16 local                               
 viridisLite    0.3.0      2018-02-01 cran (@0.3.0)                       
 withr          2.1.2      2018-03-27 Github (jimhester/withr@79d7b0d)    

Metadata

Metadata

Assignees

Labels

bugan unexpected problem or unintended behavior

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions