davidgohel / rvg

https://davidgohel.github.io/rvg/
132 stars 15 forks source link

pptx-export: Filled boxplot with constrained y-axis fills box only partially #25

Closed TillF closed 1 year ago

TillF commented 6 years ago

A boxplot with constrained y-axis fills the box only partially. half_box

do_plot = function() #do a boxplot with constrained y-axis
{
  boxplot(testdata, ylim=c(0.4, 2), col="grey")
}

#create test data
set.seed(seed = 1)
testdata = runif(n = 10)

do_plot() #this is how it should look

library(export) 

do_plot() #this is how it should look
graph2ppt(file="plot.pptx", aspectr=1.3, append=T) #this creates a box which is only filled with grey above and right of the diagonal

sessionInfo() R version 3.5.0 (2018-04-23) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 7 x64 (build 7601) Service Pack 1

Matrix products: default

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

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

other attached packages: [1] rvg_0.1.9 magrittr_1.5 officer_0.3.2 export_0.2.1 gdtools_0.1.7 [6] glmulti_1.0.7 rJava_0.9-9

loaded via a namespace (and not attached): [1] zip_1.0.0 Rcpp_0.12.16 compiler_3.5.0
[4] later_0.7.5 base64enc_0.1-3 tools_3.5.0
[7] digest_0.6.15 uuid_0.1-2 jsonlite_1.5
[10] evaluate_0.11 shiny_1.1.0 crosstalk_1.0.0
[13] yaml_2.2.0 stargazer_5.2.2 stringr_1.3.1
[16] xml2_1.2.0 knitr_1.20 htmlwidgets_1.2
[19] webshot_0.5.0 manipulateWidget_0.10.0 rprojroot_1.3-2
[22] R6_2.2.2 rgl_0.99.16 rmarkdown_1.10
[25] backports_1.1.2 promises_1.0.1 htmltools_0.3.6
[28] flextable_0.4.5 mime_0.5 xtable_1.8-2
[31] httpuv_1.4.5 miniUI_0.1.1.1 stringi_1.2.3

davidgohel commented 1 year ago

We were not able to reproduce because testdata was missing and we forgot about this issue. sorry

However, I think the issue has been fixed since.

library(ggplot2)
library(officer)
library(rvg)

graph_editable <- dml(code = {
  boxplot(count ~ spray, data = InsectSprays, col = "lightgray")
})

doc <- read_pptx()
doc <- add_slide(doc)
doc <- ph_with(doc, graph_editable, location = ph_location_fullsize())

print(doc, target = "ggbg.pptx") |> browseURL()
Capture d’écran 2022-12-19 à 11 50 25