slowkow / ggrepel

:round_pushpin: Repel overlapping text labels away from each other in your ggplot2 figures.
https://ggrepel.slowkow.com
GNU General Public License v3.0
1.21k stars 95 forks source link

Labels disappear in Rmd "Show in New Window" #121

Closed gregleleu closed 5 years ago

gregleleu commented 5 years ago

Summary

I use Rmd notebooks in R studio, with plots displayed in the chunk output. Rstudio lets you open these outputs in a new window (e.g. to have a bigger view). When opening a new window with the plot labels disappear, I guess they are not redrawn?

Version information

Using ggrepel 0.8.0.9C, but it's been like that for ever.

Here is the output from sessionInfo() in my R session:

R version 3.5.1 (2018-07-02)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS  10.14.1

Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.5/Resources/lib/libRlapack.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] ggraph_1.0.2       igraph_1.2.2       ggmosaic_0.2.0     leaflet_2.0.2      sf_0.7-1           future.apply_1.0.1 bindrcpp_0.2.2    
 [8] rvest_0.3.2        xml2_1.2.0         furrr_0.1.0        future_1.10.0      magrittr_1.5       forcats_0.3.0      stringr_1.3.1     
[15] dplyr_0.7.7        purrr_0.2.5        readr_1.1.1        tidyr_0.8.2        tibble_1.4.2       ggplot2_3.1.0      tidyverse_1.2.1   

loaded via a namespace (and not attached):
  [1] utf8_1.1.4          proto_1.0.0         tidyselect_0.2.5    lme4_1.1-18-1       RSQLite_2.1.1       htmlwidgets_1.3    
  [7] grid_3.5.1          munsell_0.5.0       codetools_0.2-15    units_0.6-1         chron_2.3-53        smbinning_0.7      
 [13] withr_2.1.2         colorspace_1.3-2    knitr_1.20          rstudioapi_0.8      stats4_3.5.1        ROCR_1.0-7         
 [19] TTR_0.23-4          listenv_0.7.0       labeling_0.3        rstan_2.18.2        urltools_1.7.1      farver_1.0         
 [25] bit64_0.9-7         rprojroot_1.3-2     xfun_0.4            ggthemes_4.0.1      productplots_0.1.1  R6_2.3.0           
 [31] dlookr_0.3.2        bitops_1.0-6        assertthat_0.2.0    promises_1.0.1      networkD3_0.4       scales_1.0.0       
 [37] nnet_7.3-12         debugme_1.1.0       gtable_0.2.0        globals_0.12.4      processx_3.2.0      sandwich_2.5-0     
 [43] rlang_0.3.0.1       splines_3.5.1       lazyeval_0.2.1      acepack_1.4.1       inline_0.3.15       mapview_2.6.0      
 [49] broom_0.5.0         checkmate_1.8.5     yaml_2.2.0          reshape2_1.4.3      abind_1.4-5         modelr_0.1.2       
 [55] crosstalk_1.0.0     backports_1.1.2     httpuv_1.4.5        quantmod_0.4-13     Hmisc_4.1-1         rmapshaper_0.4.1   
 [61] inum_1.0-0          tools_3.5.1         tcltk_3.5.1         spData_0.2.9.4      gplots_3.0.1        kableExtra_0.9.0   
 [67] raster_2.8-4        RColorBrewer_1.1-2  jsonvalidate_1.0.0  gsubfn_0.7          Rcpp_1.0.0          plyr_1.8.4         
 [73] base64enc_0.1-3     classInt_0.2-3      prettyunits_1.0.2   ps_1.2.1            rpart_4.1-13        sqldf_0.4-11       
 [79] viridis_0.5.1       zoo_1.8-4           ggrepel_0.8.0.9000  haven_1.1.2         cluster_2.0.7-1     fs_1.2.6           
 [85] tinytex_0.9         DataExplorer_0.7.0  data.table_1.11.8   magick_2.0          openxlsx_4.1.0      triebeard_0.3.0    
 [91] mvtnorm_1.0-8       mitml_0.3-6         htmltidy_0.4.0      matrixStats_0.54.0  hms_0.4.2           RcmdrMisc_2.5-1    
 [97] mime_0.6            evaluate_0.12       xtable_1.8-3        XML_3.98-1.16       DMwR_0.4.1          rio_0.5.10         
[103] readxl_1.1.0.9000   gridExtra_2.3       compiler_3.5.1      mice_3.3.0          KernSmooth_2.23-15  V8_1.5             
[109] crayon_1.3.4        StanHeaders_2.18.0  minqa_1.2.4         htmltools_0.3.6     later_0.7.5         Formula_1.2-3      
[115] libcoin_1.0-1       lubridate_1.7.4     DBI_1.0.0           tweenr_1.0.0        corrplot_0.84       MASS_7.3-51.1      
[121] Matrix_1.2-15       car_3.0-2           cli_1.0.1           gdata_2.18.0        parallel_3.5.1      bindr_0.1.1        
[127] pan_1.6             pkgconfig_2.0.2     prettydoc_0.2.1     foreign_0.8-71      sp_1.3-1            plotly_4.8.0       
[133] geojsonlint_0.2.0   webshot_0.5.1       callr_3.0.0         digest_0.6.18       janitor_1.1.1       rmarkdown_1.10     
[139] cellranger_1.1.0    htmlTable_1.12      nortest_1.0-4       curl_3.2            shiny_1.2.0         gtools_3.8.1       
[145] satellite_1.0.1     jomo_2.6-4          nloptr_1.2.1        nlme_3.1-137        jsonlite_1.5        carData_3.0-2      
[151] fansi_0.4.0         viridisLite_0.3.0   pillar_1.3.0        loo_2.0.0           lattice_0.20-38     pkgbuild_1.0.2     
[157] httr_1.3.1          survival_2.43-1     glue_1.3.0          xts_0.11-2          zip_1.0.0           png_0.1-7          
[163] bit_1.1-14          ggforce_0.1.3       class_7.3-14        stringi_1.2.4       blob_1.1.1          moments_0.14       
[169] partykit_1.2-2      latticeExtra_0.6-28 caTools_1.17.1.1    memoise_1.1.0       styler_1.0.2        e1071_1.7-0     
slowkow commented 5 years ago

Hi Greg, thanks for describing your issue.

I'm still a bit hazy on exactly what you're experiencing. I don't think I could reproduce this issue myself based on your description.

Could I ask you to please break it down into a set of steps, ideally with a minimal snippet of code that I can run in my own RStudio? I'd like to follow along and see if I get the same behavior on my machine.

Thanks!

gregleleu commented 5 years ago

Sure,

Super simple example:

library(ggplot2)
library(ggrepel)
library(dplyr)

ggdata <- diamonds %>% 
  group_by(cut) %>% 
  summarise_at(vars(depth, table), mean)

ggdata %>% 
  ggplot() +
  geom_point(aes(x = depth, y = table)) +
  geom_text_repel(aes(x = depth, y = table, label = cut))

Works fine in the normal chunk output:

image

But completely disappears in the new window (I think they're called satellite windows):

image

In latest Rstudio daily (1.2.1114) but it's been like that always. Session info:

R version 3.5.1 (2018-07-02)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS  10.14.1

Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.5/Resources/lib/libRlapack.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] dplyr_0.7.8        ggrepel_0.8.0.9000 ggplot2_3.1.0     

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.0       rstudioapi_0.8   knitr_1.20       bindr_0.1.1      magrittr_1.5     tidyselect_0.2.5
 [7] munsell_0.5.0    colorspace_1.3-2 R6_2.3.0         rlang_0.3.0.1    plyr_1.8.4       tools_3.5.1     
[13] grid_3.5.1       gtable_0.2.0     withr_2.1.2      lazyeval_0.2.1   assertthat_0.2.0 tibble_1.4.2    
[19] crayon_1.3.4     bindrcpp_0.2.2   purrr_0.2.5      glue_1.3.0       labeling_0.3     compiler_3.5.1  
[25] pillar_1.3.0     scales_1.0.0     pkgconfig_2.0.2 
joshbiology commented 5 years ago

I am seeing this issue as well. For me, the redraw occurs after I restart my RStudio session and open up an old RMD. All the ggrepel labels will be gone from my plots.

SebastianHesse commented 5 years ago

I have the same issue woking with mark-down. The ggrepel labels are shown correctly in the graphic directly implemented in the markdown script but when I click "show in new window" at the upper right side off the graph (eg to look at it a bigger size), the labels disappear.

slowkow commented 5 years ago

I was able to reproduce the issue on my laptop:

https://vimeo.com/318265708#t=52s

It seems everything works as expected, except for Show in New Window

We should contact RStudio developers and ask if they have any ideas about why this is happening.

slowkow commented 5 years ago

It seems this is a bug in RStudio, not ggrepel.