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

ggplot2 charts have bolded text when using some templates and rvg::dml #44

Open
daviddiviny opened this issue Nov 3, 2021 · 3 comments

Comments

@daviddiviny
Copy link

This is a difficult issue to debug as the issue appears to arise from a quirk of the underlying template.

My summary of the issue is that ggplot2 charts have bolded text when using some templates and rvg::dml . The text is not bolded when using the default template in officer or when exporting to PPTX without using rvg::dml.

My question is what do I need to change in the PPTX template?

An example template where this occurs is here: sample_report_template.pptx.

A reprex follows:

library(tidyverse)
library(rvg)
library(officer)


plot <- ggplot(mtcars, aes(x = disp, y = mpg)) +
  geom_point()

plot_rvg <- dml(ggobj = plot)

ppt_template <- read_pptx("new_template.pptx") %>%
  add_slide(layout = "standard", master = "default") %>%
  ph_with(plot, location = ph_location(left = 1.09, top = 3.03, height = 3.7, width = 9.4)) %>%
  add_slide(layout = "standard", master = "default") %>%
  ph_with(plot_rvg, location = ph_location(left = 1.09, top = 3.03, height = 3.7, width = 9.4))

print(ppt_template, "sample_report_template.pptx")


ppt_default <- read_pptx() %>%
  add_slide(layout = "Title and Content", master = "Office Theme") %>%
  ph_with(plot_rvg, location = ph_location(left = 1.09, top = 3.03, height = 3.7, width = 9.4))

print(ppt_default, "sample_report_default.pptx")


Session info.

R version 4.0.3 (2020-10-10)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19043)

Matrix products: default

locale:
[1] LC_COLLATE=English_Australia.1252 
[2] LC_CTYPE=English_Australia.1252   
[3] LC_MONETARY=English_Australia.1252
[4] LC_NUMERIC=C                      
[5] LC_TIME=English_Australia.1252    

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

other attached packages:
 [1] gdtools_0.2.3   officer_0.4.0   rvg_0.2.5      
 [4] forcats_0.5.0   stringr_1.4.0   dplyr_1.0.7    
 [7] purrr_0.3.4     readr_2.0.2     tidyr_1.1.4    
[10] tibble_3.1.5    ggplot2_3.3.3   tidyverse_1.3.0
[13] clipr_0.7.1    

loaded via a namespace (and not attached):
 [1] tidyselect_1.1.1  haven_2.3.1      
 [3] colorspace_2.0-2  vctrs_0.3.8      
 [5] generics_0.1.0    utf8_1.2.2       
 [7] rlang_0.4.11      pillar_1.6.4     
 [9] glue_1.4.2        withr_2.4.2      
[11] DBI_1.1.1         dbplyr_2.0.0     
[13] modelr_0.1.8      readxl_1.3.1     
[15] uuid_0.1-4        lifecycle_1.0.1  
[17] munsell_0.5.0     gtable_0.3.0     
[19] cellranger_1.1.0  rvest_1.0.0      
[21] zip_2.1.1         labeling_0.4.2   
[23] tzdb_0.1.2        fansi_0.5.0      
[25] broom_0.7.6       Rcpp_1.0.7       
[27] scales_1.1.1      backports_1.2.1  
[29] jsonlite_1.7.2    farver_2.1.0     
[31] fs_1.5.0          systemfonts_0.3.2
[33] digest_0.6.27     hms_1.1.1        
[35] stringi_1.7.5     grid_4.0.3       
[37] cli_3.0.1         tools_4.0.3      
[39] magrittr_2.0.1    crayon_1.4.1     
[41] pkgconfig_2.0.3   ellipsis_0.3.2   
[43] xml2_1.3.2        reprex_0.3.0     
[45] lubridate_1.8.0   assertthat_0.2.1 
[47] httr_1.4.2        rstudioapi_0.13  
[49] R6_2.5.1          compiler_4.0.3 
@daviddiviny
Copy link
Author

I wonder whether this is related to davidgohel/officer#315

@davidgohel
Copy link
Owner

This one will be difficult to fix. I had a look, the xml is not defining any bold attribute, it means that it inherits that from a global property... I don't know which one

@davidgohel
Copy link
Owner

yes, maybe it could be related to davidgohel/officer#315, setting bold to false for each string

@davidgohel davidgohel transferred this issue from davidgohel/officer Nov 5, 2021
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