Skip to content

Plot gets squashed downwards when RMarkdown chunk output is shown in new window when using ggtext's element_markdown() #8101

Open

Description

@AndrewKostandy

System details

RStudio Edition : Desktop or Server
RStudio Version : 1.3.1073 & 1.3.1093 & 1.4.714
OS Version      : macOS Catalina 10.15.7
R Version       : 4.0.2 (2020-06-22)

Problem & steps to reproduce it

With the ggtext package, 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 had posted an issue at the ggtext repo initially and the package creator suggested I post it here as well.

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
  • I have read the guide for submitting good bug reports.
  • I have installed the latest version of RStudio, and confirmed that the issue still persists.
  • If I am reporting a RStudio crash, I have included a diagnostics report.
  • I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.

Activity

  1. added this to the Later milestone on Oct 19, 2020
  2. mikebessuille commented on Oct 19, 2020

    @mikebessuille
    Contributor

    Thank you for all this great detail! While it is too late to consider this for 1.4, we will consider it in an upcoming release.

  3. AndrewKostandy commented on Oct 20, 2020

    @AndrewKostandy
    Author

    Alright. Thank you Mike.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions