Skip to content

Scale expand value from scales ignored when coord_cartesian ylim is used #3270

Closed
@brodieG

Description

@brodieG

It would be desirable to be able to specify 'expand' values in conjunction with coord_cartesian(ylim=...). That does not appear to work, as the expand values are reverted back to defaults. If you agree the current behavior is unexpected I can look into a PR.

library(ggplot2)
p <- ggplot(data.frame(x='a', y=100)) +
  geom_col(aes(x, y)) +
  scale_y_continuous(expand=expand_scale(mult=c(0.05, 0.50)))
p + ggtitle('Simple')

p + ggtitle('w/ coord_cart lim') +
  coord_cartesian(ylim=c(0, 100))

p + ggtitle('w/ coord_cart lim expand false') +
  coord_cartesian(ylim=c(0, 100), expand=FALSE)

Created on 2019-04-24 by the reprex package (v0.2.1)

Session info
devtools::session_info()
#> Session info -------------------------------------------------------------
#>  setting  value                       
#>  version  R version 3.5.3 (2019-03-11)
#>  system   x86_64, darwin15.6.0        
#>  ui       X11                         
#>  language (EN)                        
#>  collate  en_US.UTF-8                 
#>  tz       America/New_York            
#>  date     2019-04-24
#> Packages -----------------------------------------------------------------
#>  package    * version date       source                         
#>  assertthat   0.2.1   2019-03-21 CRAN (R 3.5.2)                 
#>  backports    1.1.2   2017-12-13 CRAN (R 3.5.0)                 
#>  base       * 3.5.3   2019-03-13 local                          
#>  colorspace   1.3-2   2016-12-14 cran (@1.3-2)                  
#>  compiler     3.5.3   2019-03-13 local                          
#>  crayon       1.3.4   2017-09-16 CRAN (R 3.5.0)                 
#>  curl         3.2     2018-03-28 CRAN (R 3.5.0)                 
#>  datasets   * 3.5.3   2019-03-13 local                          
#>  devtools     1.13.6  2018-06-27 CRAN (R 3.5.0)                 
#>  digest       0.6.18  2018-10-10 cran (@0.6.18)                 
#>  dplyr        0.8.0.1 2019-02-15 CRAN (R 3.5.2)                 
#>  evaluate     0.10.1  2017-06-24 CRAN (R 3.5.0)                 
#>  ggplot2    * 3.1.1   2019-04-07 CRAN (R 3.5.2)                 
#>  glue         1.3.0   2018-08-27 Github (tidyverse/glue@4e74901)
#>  graphics   * 3.5.3   2019-03-13 local                          
#>  grDevices  * 3.5.3   2019-03-13 local                          
#>  grid         3.5.3   2019-03-13 local                          
#>  gtable       0.2.0   2016-02-26 cran (@0.2.0)                  
#>  htmltools    0.3.6   2017-04-28 CRAN (R 3.5.0)                 
#>  httr         1.3.1   2017-08-20 CRAN (R 3.5.0)                 
#>  knitr        1.20    2018-02-20 CRAN (R 3.5.0)                 
#>  labeling     0.3     2014-08-23 cran (@0.3)                    
#>  lazyeval     0.2.1   2017-10-29 cran (@0.2.1)                  
#>  magrittr     1.5     2014-11-22 cran (@1.5)                    
#>  memoise      1.1.0   2017-04-21 CRAN (R 3.5.0)                 
#>  methods    * 3.5.3   2019-03-13 local                          
#>  mime         0.5     2016-07-07 CRAN (R 3.5.0)                 
#>  munsell      0.5.0   2018-06-12 cran (@0.5.0)                  
#>  pillar       1.3.1   2018-12-15 CRAN (R 3.5.0)                 
#>  pkgconfig    2.0.2   2018-08-16 cran (@2.0.2)                  
#>  plyr         1.8.4   2016-06-08 cran (@1.8.4)                  
#>  purrr        0.3.2   2019-03-15 CRAN (R 3.5.2)                 
#>  R6           2.3.0   2018-10-04 cran (@2.3.0)                  
#>  Rcpp         1.0.1   2019-03-17 CRAN (R 3.5.2)                 
#>  rlang        0.3.1   2019-01-08 CRAN (R 3.5.2)                 
#>  rmarkdown    1.10    2018-06-11 CRAN (R 3.5.0)                 
#>  rprojroot    1.3-2   2018-01-03 CRAN (R 3.5.0)                 
#>  scales       1.0.0   2018-08-09 cran (@1.0.0)                  
#>  stats      * 3.5.3   2019-03-13 local                          
#>  stringi      1.2.3   2018-06-12 cran (@1.2.3)                  
#>  stringr      1.3.1   2018-05-10 cran (@1.3.1)                  
#>  tibble       2.1.1   2019-03-16 CRAN (R 3.5.2)                 
#>  tidyselect   0.2.5   2018-10-11 CRAN (R 3.5.0)                 
#>  tools        3.5.3   2019-03-13 local                          
#>  utils      * 3.5.3   2019-03-13 local                          
#>  withr        2.1.2   2018-03-15 CRAN (R 3.5.0)                 
#>  xml2         1.2.0   2018-01-24 CRAN (R 3.5.0)                 
#>  yaml         2.2.0   2018-07-25 CRAN (R 3.5.0)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions