Skip to content
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

Facet labels on the left are not clipped, but all others are #2772

Closed
paleolimbot opened this issue Jul 23, 2018 · 1 comment · Fixed by #3068
Closed

Facet labels on the left are not clipped, but all others are #2772

paleolimbot opened this issue Jul 23, 2018 · 1 comment · Fixed by #3068

Comments

@paleolimbot
Copy link
Member

Any time a facet label is drawn on the left, its contents are not clipped as they are in all other directions. I would submit a PR but am unsure why this is happening, because when they are drawn in facet-grid, the clip is set to "on", and the drawing of strips in facet wrap is complicated and involves two helper functions.

library(ggplot2)
#> Warning: package 'ggplot2' was built under R version 3.4.4

test_data <- data.frame(
  facet = c(
    rep("a very very very very very long facet name", 10),
    rep("another very very very very very long facet name", 10),
    rep("a third very very very very very long facet name", 10)
  ),
  x = runif(30),
  y = runif(30)
)

p <- ggplot(test_data, aes(x, y)) + geom_point()

# plots that don't match the rest
p + facet_grid(rows = vars(facet), switch = "both")

p + facet_wrap(vars(facet), strip.position = "left", ncol = 1)

# all combinations of facet labels
p + facet_grid(cols = vars(facet))

p + facet_grid(rows = vars(facet))

p + facet_grid(cols = vars(facet), switch = "both")

p + facet_grid(rows = vars(facet), switch = "both")

p + facet_wrap(vars(facet), strip.position = "top", nrow = 1)

p + facet_wrap(vars(facet), strip.position = "bottom", nrow = 1)

p + facet_wrap(vars(facet), strip.position = "right", ncol = 1)

p + facet_wrap(vars(facet), strip.position = "left", ncol = 1)

# session info
devtools::session_info()
#> Session info -------------------------------------------------------------
#>  setting  value                       
#>  version  R version 3.4.3 (2017-11-30)
#>  system   x86_64, darwin15.6.0        
#>  ui       X11                         
#>  language (EN)                        
#>  collate  en_CA.UTF-8                 
#>  tz       America/New_York            
#>  date     2018-07-23
#> Packages -----------------------------------------------------------------
#>  package    * version    date       source                          
#>  assertthat   0.2.0      2017-04-11 CRAN (R 3.4.0)                  
#>  backports    1.1.2      2017-12-13 CRAN (R 3.4.3)                  
#>  base       * 3.4.3      2017-12-07 local                           
#>  bindr        0.1.1      2018-03-13 cran (@0.1.1)                   
#>  bindrcpp     0.2.2      2018-03-29 CRAN (R 3.4.4)                  
#>  colorspace   1.3-2      2016-12-14 CRAN (R 3.4.0)                  
#>  compiler     3.4.3      2017-12-07 local                           
#>  datasets   * 3.4.3      2017-12-07 local                           
#>  devtools     1.13.4     2017-11-09 CRAN (R 3.4.2)                  
#>  digest       0.6.15     2018-01-28 cran (@0.6.15)                  
#>  dplyr        0.7.6      2018-06-29 CRAN (R 3.4.4)                  
#>  evaluate     0.10.1     2017-06-24 CRAN (R 3.4.1)                  
#>  ggplot2    * 3.0.0      2018-07-03 CRAN (R 3.4.4)                  
#>  glue         1.2.0      2017-10-29 CRAN (R 3.4.2)                  
#>  graphics   * 3.4.3      2017-12-07 local                           
#>  grDevices  * 3.4.3      2017-12-07 local                           
#>  grid         3.4.3      2017-12-07 local                           
#>  gtable       0.2.0      2016-02-26 CRAN (R 3.4.0)                  
#>  htmltools    0.3.6      2017-04-28 CRAN (R 3.4.0)                  
#>  knitr        1.17       2017-08-10 CRAN (R 3.4.1)                  
#>  labeling     0.3        2014-08-23 CRAN (R 3.4.0)                  
#>  lazyeval     0.2.1      2017-10-29 CRAN (R 3.4.2)                  
#>  magrittr     1.5        2014-11-22 CRAN (R 3.4.0)                  
#>  memoise      1.1.0      2017-04-21 CRAN (R 3.4.0)                  
#>  methods    * 3.4.3      2017-12-07 local                           
#>  munsell      0.4.3      2016-02-13 CRAN (R 3.4.0)                  
#>  pillar       1.1.0      2018-01-14 cran (@1.1.0)                   
#>  pkgconfig    2.0.1      2017-03-21 CRAN (R 3.4.0)                  
#>  plyr         1.8.4      2016-06-08 CRAN (R 3.4.0)                  
#>  purrr        0.2.5      2018-05-29 CRAN (R 3.4.4)                  
#>  R6           2.2.2      2017-06-17 CRAN (R 3.4.0)                  
#>  Rcpp         0.12.17    2018-05-18 cran (@0.12.17)                 
#>  reshape2     1.4.3      2017-12-11 CRAN (R 3.4.3)                  
#>  rlang        0.2.1      2018-05-30 CRAN (R 3.4.4)                  
#>  rmarkdown    1.8        2017-11-17 CRAN (R 3.4.2)                  
#>  rprojroot    1.3-1      2017-12-18 CRAN (R 3.4.3)                  
#>  scales       0.5.0.9000 2018-06-11 Github (hadley/scales@c28066a)  
#>  stats      * 3.4.3      2017-12-07 local                           
#>  stringi      1.2.3      2018-06-12 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)                   
#>  tidyselect   0.2.4      2018-02-26 cran (@0.2.4)                   
#>  tools        3.4.3      2017-12-07 local                           
#>  utils      * 3.4.3      2017-12-07 local                           
#>  withr        2.1.2      2018-06-11 Github (jimhester/withr@dbcd7cd)
#>  yaml         2.1.16     2017-12-12 CRAN (R 3.4.3)

Created on 2018-07-23 by the reprex
package
(v0.2.0).

@lock
Copy link

lock bot commented Jul 18, 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 Jul 18, 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 a pull request may close this issue.

1 participant