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

geom_point points fill opacity is lost while converting to dml #52

Open
krystian8207 opened this issue Jan 17, 2023 · 0 comments
Open

Comments

@krystian8207
Copy link

Hi @davidgohel.
Thank you for the great work you're doing here developing the package!

I realized when converting ggplots storing points to dml we may lose alpha property information.
It happens when color is unspecified but alpha is provided.

Reproducible example:

library(ggplot2)
library(rvg)

dml_file <- tempfile()
dml_pptx(file = dml_file, standalone = FALSE)

ggplot(mtcars[1, ], aes(wt, mpg)) + 
  geom_point(alpha = 0.5, size = 10) +
  labs(
    x = NULL,
    y = NULL
  ) +
  theme_minimal() +
  theme(
    panel.grid.major = element_blank(),
    panel.grid.minor = element_blank(),
    axis.text = element_blank(),
    axis.title = element_blank()
  )
dev.off()
dml_gg <- xml2::read_xml(dml_file)

xml_children(xml_child(xml_child(dml_gg, 4), 2)) %>% lapply(xml_name) %>% unlist()
[1] "xfrm"     "prstGeom" "ln"

When color is precised everything is fine, alpha can be extracted from shape's "p:spPr/a:solidFill" child.

I'd be grateful if you could take a look at it. Thank you.

sessionInfo():

R version 4.1.0 (2021-05-18)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 20.04.2 LTS

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3
LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/liblapack.so.3

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C               LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8     LC_MONETARY=en_US.UTF-8   
 [6] LC_MESSAGES=en_US.UTF-8    LC_PAPER=en_US.UTF-8       LC_NAME=C                  LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

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

other attached packages:
 [1] ggtext_0.1.2       gslideR_0.0.0.9000 gdtools_0.2.4      magrittr_2.0.3     xml2_1.3.3         rvg_0.3.1          officer_0.5.0     
 [8] ggimage_0.3.1      ggplot2_3.4.0      googleAuthR_2.0.0 

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.9          lattice_0.20-45     assertthat_0.2.1    rprojroot_2.0.3     digest_0.6.31       utf8_1.2.2         
 [7] R6_2.5.1            httr_1.4.4          pillar_1.8.1        ggfun_0.0.9         yulab.utils_0.0.6   rlang_1.0.6        
[13] curl_4.3.3          uuid_1.1-0          rstudioapi_0.14     magick_2.7.3        Matrix_1.5-3        desc_1.4.2         
[19] labeling_0.4.2      splines_4.1.0       stringr_1.5.0       munsell_0.5.0       gridtext_0.1.5      compiler_4.1.0     
[25] httpuv_1.6.7        xfun_0.36           pkgconfig_2.0.3     systemfonts_1.0.4   gridGraphics_0.5-1  mgcv_1.8-41        
[31] tibble_3.1.8        fansi_1.0.3         withr_2.5.0         later_1.3.0         commonmark_1.8.1    rgoogleslides_0.3.2
[37] nlme_3.1-161        jsonlite_1.8.4      gtable_0.3.1        lifecycle_1.0.3     scales_1.2.1        zip_2.2.2          
[43] stringi_1.7.8       cli_3.5.0           cachem_1.0.6        farver_2.1.1        renv_0.15.4         fs_1.5.2           
[49] promises_1.2.0.1    vctrs_0.5.1         tools_4.1.0         ggplotify_0.1.0     glue_1.6.2          markdown_1.4       
[55] purrr_1.0.0         pkgload_1.3.2       fastmap_1.1.0       colorspace_2.0-3    gargle_1.2.1        memoise_2.0.1
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

1 participant