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

Better labelling and label dodge for gg_season #115

Closed
emitanaka opened this issue Aug 14, 2020 · 2 comments
Closed

Better labelling and label dodge for gg_season #115

emitanaka opened this issue Aug 14, 2020 · 2 comments

Comments

@emitanaka
Copy link

The labels appear on top of the line currently. Ideally when labels = "right", I'd want the labels to appear on the right of the line. Additionally, it would be great if the labels would dodge each other much like the n.dodge = 2 feature in guide_axis.

library(tidyverse)
#> Warning: package 'tidyverse' was built under R version 4.0.2
library(feasts)
#> Warning: package 'feasts' was built under R version 4.0.2
#> Loading required package: fabletools
#> Warning: package 'fabletools' was built under R version 4.0.2
tsibbledata::aus_retail %>%
  filter(
    State == "Victoria",
    Industry == "Cafes, restaurants and catering services"
  ) %>%
  gg_season(Turnover, labels = "right")

Created on 2020-08-14 by the reprex package (v0.3.0.9001)

Session info
sessioninfo::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#>  setting  value                       
#>  version  R version 4.0.1 (2020-06-06)
#>  os       macOS Catalina 10.15.6      
#>  system   x86_64, darwin17.0          
#>  ui       X11                         
#>  language (EN)                        
#>  collate  en_AU.UTF-8                 
#>  ctype    en_AU.UTF-8                 
#>  tz       Australia/Melbourne         
#>  date     2020-08-14                  
#> 
#> ─ Packages ───────────────────────────────────────────────────────────────────
#>  package        * version    date       lib source                           
#>  anytime          0.3.7      2020-01-20 [2] CRAN (R 4.0.0)                   
#>  assertthat       0.2.1      2019-03-21 [2] CRAN (R 4.0.0)                   
#>  backports        1.1.8      2020-06-17 [1] CRAN (R 4.0.0)                   
#>  blob             1.2.1      2020-01-20 [2] CRAN (R 4.0.0)                   
#>  broom            0.7.0      2020-07-09 [1] CRAN (R 4.0.2)                   
#>  cellranger       1.1.0      2016-07-27 [2] CRAN (R 4.0.0)                   
#>  cli              2.0.2      2020-02-28 [2] CRAN (R 4.0.0)                   
#>  colorspace       1.4-1      2019-03-18 [1] CRAN (R 4.0.2)                   
#>  crayon           1.3.4      2017-09-16 [2] CRAN (R 4.0.0)                   
#>  curl             4.3        2019-12-02 [2] CRAN (R 4.0.0)                   
#>  DBI              1.1.0      2019-12-15 [1] CRAN (R 4.0.2)                   
#>  dbplyr           1.4.4      2020-05-27 [1] CRAN (R 4.0.2)                   
#>  digest           0.6.25     2020-02-23 [2] CRAN (R 4.0.0)                   
#>  distributional   0.2.0      2020-08-03 [1] CRAN (R 4.0.2)                   
#>  dplyr          * 1.0.1      2020-07-26 [1] Github (tidyverse/dplyr@16647fc) 
#>  ellipsis         0.3.1      2020-05-15 [2] CRAN (R 4.0.0)                   
#>  evaluate         0.14       2019-05-28 [2] CRAN (R 4.0.0)                   
#>  fabletools     * 0.2.0      2020-06-15 [1] CRAN (R 4.0.2)                   
#>  fansi            0.4.1      2020-01-08 [2] CRAN (R 4.0.0)                   
#>  farver           2.0.3.9000 2020-07-24 [1] Github (thomasp85/farver@f1bcb56)
#>  feasts         * 0.1.4      2020-06-17 [1] CRAN (R 4.0.2)                   
#>  forcats        * 0.5.0      2020-03-01 [2] CRAN (R 4.0.0)                   
#>  fs               1.5.0      2020-07-31 [1] CRAN (R 4.0.2)                   
#>  generics         0.0.2      2018-11-29 [2] CRAN (R 4.0.0)                   
#>  ggplot2        * 3.3.2      2020-06-19 [1] CRAN (R 4.0.0)                   
#>  glue             1.4.1      2020-05-13 [1] CRAN (R 4.0.2)                   
#>  gtable           0.3.0      2019-03-25 [2] CRAN (R 4.0.0)                   
#>  haven            2.3.1      2020-06-01 [2] CRAN (R 4.0.0)                   
#>  highr            0.8        2019-03-20 [2] CRAN (R 4.0.0)                   
#>  hms              0.5.3      2020-01-08 [2] CRAN (R 4.0.0)                   
#>  htmltools        0.5.0      2020-06-16 [1] CRAN (R 4.0.2)                   
#>  httr             1.4.2      2020-07-20 [1] CRAN (R 4.0.2)                   
#>  jsonlite         1.7.0      2020-06-25 [1] CRAN (R 4.0.1)                   
#>  knitr            1.29       2020-06-23 [1] CRAN (R 4.0.2)                   
#>  labeling         0.3        2014-08-23 [2] CRAN (R 4.0.0)                   
#>  lifecycle        0.2.0      2020-03-06 [1] CRAN (R 4.0.0)                   
#>  lubridate        1.7.9      2020-06-08 [2] CRAN (R 4.0.1)                   
#>  magrittr         1.5        2014-11-22 [2] CRAN (R 4.0.0)                   
#>  mime             0.9        2020-02-04 [2] CRAN (R 4.0.0)                   
#>  modelr           0.1.8      2020-05-19 [2] CRAN (R 4.0.0)                   
#>  munsell          0.5.0      2018-06-12 [2] CRAN (R 4.0.0)                   
#>  pillar           1.4.6      2020-07-10 [1] CRAN (R 4.0.1)                   
#>  pkgconfig        2.0.3      2019-09-22 [2] CRAN (R 4.0.0)                   
#>  purrr          * 0.3.4      2020-04-17 [2] CRAN (R 4.0.0)                   
#>  R6               2.4.1      2019-11-12 [2] CRAN (R 4.0.0)                   
#>  Rcpp             1.0.5      2020-07-06 [1] CRAN (R 4.0.0)                   
#>  readr          * 1.3.1      2018-12-21 [2] CRAN (R 4.0.0)                   
#>  readxl           1.3.1      2019-03-13 [2] CRAN (R 4.0.0)                   
#>  reprex           0.3.0.9001 2020-08-08 [1] Github (tidyverse/reprex@9594ee9)
#>  rlang            0.4.7      2020-07-09 [1] CRAN (R 4.0.1)                   
#>  rmarkdown        2.3        2020-06-18 [1] CRAN (R 4.0.2)                   
#>  rstudioapi       0.11       2020-02-07 [2] CRAN (R 4.0.0)                   
#>  rvest            0.3.6      2020-07-25 [1] CRAN (R 4.0.2)                   
#>  scales           1.1.1      2020-05-11 [2] CRAN (R 4.0.0)                   
#>  sessioninfo      1.1.1      2018-11-05 [2] CRAN (R 4.0.0)                   
#>  stringi          1.4.6      2020-02-17 [2] CRAN (R 4.0.0)                   
#>  stringr        * 1.4.0      2019-02-10 [2] CRAN (R 4.0.0)                   
#>  styler           1.3.2      2020-02-23 [1] CRAN (R 4.0.1)                   
#>  tibble         * 3.0.3      2020-07-10 [1] CRAN (R 4.0.1)                   
#>  tidyr          * 1.1.0      2020-05-20 [2] CRAN (R 4.0.0)                   
#>  tidyselect       1.1.0      2020-05-11 [2] CRAN (R 4.0.0)                   
#>  tidyverse      * 1.3.0      2019-11-21 [1] CRAN (R 4.0.2)                   
#>  tsibble          0.9.1      2020-06-20 [2] CRAN (R 4.0.1)                   
#>  tsibbledata      0.2.0      2020-06-04 [1] CRAN (R 4.0.2)                   
#>  vctrs            0.3.2.9000 2020-07-26 [1] Github (r-lib/vctrs@df8a659)     
#>  withr            2.2.0      2020-04-20 [2] CRAN (R 4.0.0)                   
#>  xfun             0.16       2020-07-24 [1] CRAN (R 4.0.2)                   
#>  xml2             1.3.2      2020-04-23 [2] CRAN (R 4.0.0)                   
#>  yaml             2.2.1      2020-02-01 [1] CRAN (R 4.0.2)                   
#> 
#> [1] /Users/etan0038/Library/R/4.0/library
#> [2] /Library/Frameworks/R.framework/Versions/4.0/Resources/library
mitchelloharawild added a commit that referenced this issue Oct 6, 2020
@mitchelloharawild
Copy link
Member

These labels are now aligned outward, however the panel size does not update for geom_text() elements, and so some manual limit expansion is needed based on the number of characters.

library(tidyverse)
library(feasts)
#> Loading required package: fabletools
tsibbledata::aus_retail %>%
  filter(
    State == "Victoria",
    Industry == "Cafes, restaurants and catering services"
  ) %>%
  gg_season(Turnover, labels = "right")

Created on 2020-10-06 by the reprex package (v0.3.0)

@mitchelloharawild
Copy link
Member

Closing as expanding axis to accommodate text is an issue better suited to resolving in ggplot2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants