简体   繁体   中英

R: ggplot2 plot with ggupset and hrbrthemes::theme_upsum(): Superfluous "at" appears at x-axis label

I am using hrbrthemes::theme_ipsum() with most of my plots, but now I'm encountering odd behaviour while using ggupset : An extra "at" above the x-axis label that I can neither find the origin of nor can get rid of.

If anyone could try to explain what's going on here (and how to get rid of it), that'd be great.
Note that I tried both the current CRAN and GitHub versions of hrbrthemes .

Demonstration:

library(ggplot2)
library(dplyr, warn.conflicts = FALSE)
library(ggupset) # https://github.com/const-ae/ggupset
library(hrbrthemes) # https://github.com/hrbrmstr/hrbrthemes

# starting with a perfectly normal upset plot from ggupset's README
p <- tidy_movies %>%
  distinct(title, year, length, .keep_all = TRUE) %>%
  head(100) %>% # smaller dataset for faster(ish) plotting
  ggplot(aes(x=Genres)) +
  geom_bar() +
  scale_x_upset(order_by = "degree") +
  labs(x = "x-label for demonstration purposes")

looks fine:

p
#> Warning: Removed 30 rows containing non-finite values (stat_count).

Now with theme_ipsum() the easy way

p_hrbr <- p + hrbrthemes::theme_ipsum()

But nope, something seems to conflict here.

p_hrbr
#> Warning: Removed 30 rows containing non-finite values (stat_count).
#> Error: Insufficient values in manual scale. 2 needed but only 0 provided.

But in my actual usecase I set the theme globally, like so:

theme_set(hrbrthemes::theme_ipsum())

The original plot, now with theme_ipsum. Notice the x-axis on the bottom right.

p
#> Warning: Removed 30 rows containing non-finite values (stat_count).

I can't find any label set to "at". at what?

p$labels
#> $x
#> [1] "x-label for demonstration purposes"
#> 
#> $y
#> [1] "count"
#> 
#> $weight
#> [1] "weight"

Resetting to the default theme:

theme_set(theme_gray())

It's gone

p
#> Warning: Removed 30 rows containing non-finite values (stat_count).

Session info

devtools::session_info(pkgs = c("ggplot2", "hrbrthemes", "ggupset"))
#> ─ Session info ───────────────────────────────────────────────────────────────
#>  setting  value                       
#>  version  R version 3.6.3 (2020-02-29)
#>  os       macOS Catalina 10.15.3      
#>  system   x86_64, darwin15.6.0        
#>  ui       X11                         
#>  language (EN)                        
#>  collate  en_US.UTF-8                 
#>  ctype    en_US.UTF-8                 
#>  tz       Europe/Berlin               
#>  date     2020-03-24                  
#> 
#> ─ Packages ───────────────────────────────────────────────────────────────────
#>  package      * version  date       lib source                              
#>  assertthat     0.2.1    2019-03-21 [1] CRAN (R 3.6.0)                      
#>  backports      1.1.5    2019-10-02 [1] CRAN (R 3.6.0)                      
#>  base64enc      0.1-3    2015-07-28 [1] CRAN (R 3.6.0)                      
#>  callr          3.4.2    2020-02-12 [1] CRAN (R 3.6.2)                      
#>  cli            2.0.2    2020-02-28 [1] CRAN (R 3.6.2)                      
#>  colorspace     1.4-1    2019-03-18 [1] CRAN (R 3.6.0)                      
#>  crayon         1.3.4    2017-09-16 [1] CRAN (R 3.6.0)                      
#>  desc           1.2.0    2018-05-01 [1] CRAN (R 3.6.0)                      
#>  digest         0.6.25   2020-02-23 [1] CRAN (R 3.6.0)                      
#>  ellipsis       0.3.0    2019-09-20 [1] CRAN (R 3.6.0)                      
#>  evaluate       0.14     2019-05-28 [1] CRAN (R 3.6.0)                      
#>  extrafont      0.17     2014-12-08 [1] CRAN (R 3.6.0)                      
#>  extrafontdb    1.0      2012-06-11 [1] CRAN (R 3.6.0)                      
#>  fansi          0.4.1    2020-01-08 [1] CRAN (R 3.6.0)                      
#>  farver         2.0.3    2020-01-16 [1] CRAN (R 3.6.0)                      
#>  gdtools        0.2.1    2019-10-14 [1] CRAN (R 3.6.0)                      
#>  ggplot2      * 3.3.0    2020-03-05 [1] CRAN (R 3.6.2)                      
#>  ggupset      * 0.1.0    2019-03-06 [1] CRAN (R 3.6.0)                      
#>  glue           1.3.2    2020-03-12 [1] CRAN (R 3.6.0)                      
#>  gtable         0.3.0    2019-03-25 [1] CRAN (R 3.6.0)                      
#>  highr          0.8      2019-03-20 [1] CRAN (R 3.6.0)                      
#>  hrbrthemes   * 0.8.0    2020-03-24 [1] Github (hrbrmstr/hrbrthemes@a599f17)
#>  htmltools      0.4.0    2019-10-04 [1] CRAN (R 3.6.0)                      
#>  isoband        0.2.0    2019-04-06 [1] CRAN (R 3.6.0)                      
#>  jsonlite       1.6.1    2020-02-02 [1] CRAN (R 3.6.0)                      
#>  knitr          1.28     2020-02-06 [1] CRAN (R 3.6.2)                      
#>  labeling       0.3      2014-08-23 [1] CRAN (R 3.6.0)                      
#>  lattice        0.20-38  2018-11-04 [2] CRAN (R 3.6.3)                      
#>  lifecycle      0.2.0    2020-03-06 [1] CRAN (R 3.6.2)                      
#>  magrittr       1.5      2014-11-22 [1] CRAN (R 3.6.0)                      
#>  markdown       1.1      2019-08-07 [1] CRAN (R 3.6.0)                      
#>  MASS           7.3-51.5 2019-12-20 [2] CRAN (R 3.6.3)                      
#>  Matrix         1.2-18   2019-11-27 [2] CRAN (R 3.6.3)                      
#>  mgcv           1.8-31   2019-11-09 [2] CRAN (R 3.6.3)                      
#>  mime           0.9      2020-02-04 [1] CRAN (R 3.6.0)                      
#>  munsell        0.5.0    2018-06-12 [1] CRAN (R 3.6.0)                      
#>  nlme           3.1-144  2020-02-06 [2] CRAN (R 3.6.3)                      
#>  pillar         1.4.3    2019-12-20 [1] CRAN (R 3.6.0)                      
#>  pkgbuild       1.0.6    2019-10-09 [1] CRAN (R 3.6.0)                      
#>  pkgconfig      2.0.3    2019-09-22 [1] CRAN (R 3.6.0)                      
#>  pkgload        1.0.2    2018-10-29 [1] CRAN (R 3.6.0)                      
#>  praise         1.0.0    2015-08-11 [1] CRAN (R 3.6.0)                      
#>  prettyunits    1.1.1    2020-01-24 [1] CRAN (R 3.6.0)                      
#>  processx       3.4.2    2020-02-09 [1] CRAN (R 3.6.0)                      
#>  ps             1.3.2    2020-02-13 [1] CRAN (R 3.6.0)                      
#>  R6             2.4.1    2019-11-12 [1] CRAN (R 3.6.0)                      
#>  RColorBrewer   1.1-2    2014-12-07 [1] CRAN (R 3.6.0)                      
#>  Rcpp           1.0.4    2020-03-17 [1] CRAN (R 3.6.0)                      
#>  rlang          0.4.5    2020-03-01 [1] CRAN (R 3.6.0)                      
#>  rmarkdown      2.1      2020-01-20 [1] CRAN (R 3.6.0)                      
#>  rprojroot      1.3-2    2018-01-03 [1] CRAN (R 3.6.0)                      
#>  rstudioapi     0.11     2020-02-07 [1] CRAN (R 3.6.0)                      
#>  Rttf2pt1       1.3.8    2020-01-10 [1] CRAN (R 3.6.0)                      
#>  scales         1.1.0    2019-11-18 [1] CRAN (R 3.6.0)                      
#>  stringi        1.4.6    2020-02-17 [1] CRAN (R 3.6.0)                      
#>  stringr        1.4.0    2019-02-10 [1] CRAN (R 3.6.0)                      
#>  systemfonts    0.1.1    2019-07-01 [1] CRAN (R 3.6.0)                      
#>  testthat       2.3.2    2020-03-02 [1] CRAN (R 3.6.0)                      
#>  tibble         2.1.3    2019-06-06 [1] CRAN (R 3.6.0)                      
#>  tinytex        0.20     2020-02-25 [1] CRAN (R 3.6.0)                      
#>  utf8           1.1.4    2018-05-24 [1] CRAN (R 3.6.0)                      
#>  vctrs          0.2.4    2020-03-10 [1] CRAN (R 3.6.0)                      
#>  viridisLite    0.3.0    2018-02-01 [1] CRAN (R 3.6.0)                      
#>  withr          2.1.2    2018-03-15 [1] CRAN (R 3.6.0)                      
#>  xfun           0.12     2020-01-13 [1] CRAN (R 3.6.0)                      
#>  yaml           2.2.1    2020-02-01 [1] CRAN (R 3.6.0)                      
#> 
#> [1] /Users/Lukas/Library/R/3.6
#> [2] /Library/Frameworks/R.framework/Versions/3.6/Resources/library

Created on 2020-03-24 by the reprex package (v0.3.0)

Update 2020-03-24: The author of ggupset has responded on GitHub and is taking a look.

The issue was caused by ggupset , and has since been fixed .

If anyone else has encountered this, you can use the current development version: remotes::install_github("const-ae/ggupset") , or wait for the CRAN release in the near future.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM