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

Plot gets squashed downwards when RMarkdown chunk output is shown in new window when using element_markdown() #55

Open
AndrewKostandy opened this issue Oct 18, 2020 · 2 comments

Comments

@AndrewKostandy
Copy link

AndrewKostandy commented Oct 18, 2020

When using element_markdown() on the plot title in an RStudio R Markdown chunk, the plot looks fine. But if we click the "Show in New Window" button near the chunk output, the plot in the new window gets squashed downwards. I'm using RStudio Version 1.3.1073.

library(tidyverse)
library(ggtext)
library(palmerpenguins)

penguins %>% 
  filter(!is.na(bill_length_mm), !is.na(bill_depth_mm)) %>% 
  ggplot(aes(bill_length_mm, bill_depth_mm, color = species)) +
  geom_point() +
  labs(title = "Title with **bold** text") +
  theme(plot.title = element_markdown())

This works fine here:

Screen Shot 2020-10-18 at 8 38 54 AM

But when we click "Show in New Window":

Screen Shot 2020-10-18 at 8 39 26 AM

A regular plot without the below line, would not get squashed:

theme(plot.title = element_markdown())

Screen Shot 2020-10-18 at 8 45 02 AM

Running the same code in the console works fine:

Screen Shot 2020-10-18 at 8 41 46 AM

Pressing the "Zoom" button on the plot result of the console works fine:

Screen Shot 2020-10-18 at 8 43 46 AM

Session info
devtools::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#>  setting  value                       
#>  version  R version 4.0.2 (2020-06-22)
#>  os       macOS Catalina 10.15.7      
#>  system   x86_64, darwin17.0          
#>  ui       X11                         
#>  language (EN)                        
#>  collate  en_CA.UTF-8                 
#>  ctype    en_CA.UTF-8                 
#>  tz       America/Toronto             
#>  date     2020-10-18                  
#> 
#> ─ Packages ───────────────────────────────────────────────────────────────────
#>  package        * version date       lib source        
#>  assertthat       0.2.1   2019-03-21 [1] CRAN (R 4.0.2)
#>  backports        1.1.10  2020-09-15 [1] CRAN (R 4.0.2)
#>  blob             1.2.1   2020-01-20 [1] CRAN (R 4.0.2)
#>  broom            0.7.1   2020-10-02 [1] CRAN (R 4.0.2)
#>  callr            3.5.0   2020-10-08 [1] CRAN (R 4.0.2)
#>  cellranger       1.1.0   2016-07-27 [1] CRAN (R 4.0.2)
#>  cli              2.0.2   2020-02-28 [1] CRAN (R 4.0.2)
#>  colorspace       1.4-1   2019-03-18 [1] CRAN (R 4.0.2)
#>  crayon           1.3.4   2017-09-16 [1] CRAN (R 4.0.2)
#>  curl             4.3     2019-12-02 [1] CRAN (R 4.0.1)
#>  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)
#>  desc             1.2.0   2018-05-01 [1] CRAN (R 4.0.2)
#>  devtools         2.3.2   2020-09-18 [1] CRAN (R 4.0.2)
#>  digest           0.6.25  2020-02-23 [1] CRAN (R 4.0.2)
#>  dplyr          * 1.0.2   2020-08-18 [1] CRAN (R 4.0.2)
#>  ellipsis         0.3.1   2020-05-15 [1] CRAN (R 4.0.2)
#>  evaluate         0.14    2019-05-28 [1] CRAN (R 4.0.1)
#>  fansi            0.4.1   2020-01-08 [1] CRAN (R 4.0.2)
#>  farver           2.0.3   2020-01-16 [1] CRAN (R 4.0.2)
#>  forcats        * 0.5.0   2020-03-01 [1] CRAN (R 4.0.2)
#>  fs               1.5.0   2020-07-31 [1] CRAN (R 4.0.2)
#>  generics         0.0.2   2018-11-29 [1] CRAN (R 4.0.2)
#>  ggplot2        * 3.3.2   2020-06-19 [1] CRAN (R 4.0.2)
#>  ggtext         * 0.1.0   2020-06-04 [1] CRAN (R 4.0.2)
#>  glue             1.4.2   2020-08-27 [1] CRAN (R 4.0.2)
#>  gridtext         0.1.1   2020-02-24 [1] CRAN (R 4.0.2)
#>  gtable           0.3.0   2019-03-25 [1] CRAN (R 4.0.2)
#>  haven            2.3.1   2020-06-01 [1] CRAN (R 4.0.2)
#>  highr            0.8     2019-03-20 [1] CRAN (R 4.0.2)
#>  hms              0.5.3   2020-01-08 [1] CRAN (R 4.0.2)
#>  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.1   2020-09-07 [1] CRAN (R 4.0.2)
#>  knitr            1.30    2020-09-22 [1] CRAN (R 4.0.2)
#>  labeling         0.3     2014-08-23 [1] CRAN (R 4.0.2)
#>  lifecycle        0.2.0   2020-03-06 [1] CRAN (R 4.0.2)
#>  lubridate        1.7.9   2020-06-08 [1] CRAN (R 4.0.2)
#>  magrittr         1.5     2014-11-22 [1] CRAN (R 4.0.2)
#>  markdown         1.1     2019-08-07 [1] CRAN (R 4.0.2)
#>  memoise          1.1.0   2017-04-21 [1] CRAN (R 4.0.2)
#>  mime             0.9     2020-02-04 [1] CRAN (R 4.0.2)
#>  modelr           0.1.8   2020-05-19 [1] CRAN (R 4.0.2)
#>  munsell          0.5.0   2018-06-12 [1] CRAN (R 4.0.2)
#>  palmerpenguins * 0.1.0   2020-07-23 [1] CRAN (R 4.0.2)
#>  pillar           1.4.6   2020-07-10 [1] CRAN (R 4.0.2)
#>  pkgbuild         1.1.0   2020-07-13 [1] CRAN (R 4.0.2)
#>  pkgconfig        2.0.3   2019-09-22 [1] CRAN (R 4.0.2)
#>  pkgload          1.1.0   2020-05-29 [1] CRAN (R 4.0.2)
#>  prettyunits      1.1.1   2020-01-24 [1] CRAN (R 4.0.2)
#>  processx         3.4.4   2020-09-03 [1] CRAN (R 4.0.2)
#>  ps               1.4.0   2020-10-07 [1] CRAN (R 4.0.2)
#>  purrr          * 0.3.4   2020-04-17 [1] CRAN (R 4.0.2)
#>  R6               2.4.1   2019-11-12 [1] CRAN (R 4.0.2)
#>  Rcpp             1.0.5   2020-07-06 [1] CRAN (R 4.0.2)
#>  readr          * 1.4.0   2020-10-05 [1] CRAN (R 4.0.2)
#>  readxl           1.3.1   2019-03-13 [1] CRAN (R 4.0.2)
#>  remotes          2.2.0   2020-07-21 [1] CRAN (R 4.0.2)
#>  reprex           0.3.0   2019-05-16 [1] CRAN (R 4.0.2)
#>  rlang            0.4.8   2020-10-08 [1] CRAN (R 4.0.2)
#>  rmarkdown        2.4     2020-09-30 [1] CRAN (R 4.0.2)
#>  rprojroot        1.3-2   2018-01-03 [1] CRAN (R 4.0.2)
#>  rvest            0.3.6   2020-07-25 [1] CRAN (R 4.0.2)
#>  scales           1.1.1   2020-05-11 [1] CRAN (R 4.0.2)
#>  sessioninfo      1.1.1   2018-11-05 [1] CRAN (R 4.0.2)
#>  stringi          1.5.3   2020-09-09 [1] CRAN (R 4.0.2)
#>  stringr        * 1.4.0   2019-02-10 [1] CRAN (R 4.0.2)
#>  testthat         2.3.2   2020-03-02 [1] CRAN (R 4.0.2)
#>  tibble         * 3.0.4   2020-10-12 [1] CRAN (R 4.0.2)
#>  tidyr          * 1.1.2   2020-08-27 [1] CRAN (R 4.0.2)
#>  tidyselect       1.1.0   2020-05-11 [1] CRAN (R 4.0.2)
#>  tidyverse      * 1.3.0   2019-11-21 [1] CRAN (R 4.0.2)
#>  usethis          1.6.3   2020-09-17 [1] CRAN (R 4.0.2)
#>  vctrs            0.3.4   2020-08-29 [1] CRAN (R 4.0.2)
#>  withr            2.3.0   2020-09-22 [1] CRAN (R 4.0.2)
#>  xfun             0.18    2020-09-29 [1] CRAN (R 4.0.2)
#>  xml2             1.3.2   2020-04-23 [1] CRAN (R 4.0.2)
#>  yaml             2.2.1   2020-02-01 [1] CRAN (R 4.0.2)
#> 
#> [1] /Library/Frameworks/R.framework/Versions/4.0/Resources/library
@clauswilke
Copy link
Collaborator

I can reproduce the issue with RStudio 1.4.714. Since it arises in one particular output window in RStudio, I would assume it has something to do with how that graphics output is generated. You may want to file a bug with RStudio as well. I don't know how to debug this on my end.

@AndrewKostandy
Copy link
Author

Thank you Claus for your quick response (and the useful package of course). I have posted an issue with RStudio as you suggested.

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