tomwenseleers / export

R package for streamlined export of graphs and data tables.
192 stars 35 forks source link

Error in export of plots containing polygons (R function polygon()) #8

Closed melaniegrieb closed 5 years ago

melaniegrieb commented 7 years ago

Plots the wrong polygon in export to Powerpoint. Other exports from R (my example contains pdf) work correctly and display the correct polygon. The error only occurs for selected polygons and not all polygons.

Attached example plots a normal distribution and shades a selected area under the curve. For easier bug reporting, a fresh R session was started before sourcing the example.

Attached files: export-example.txt - Reproducible example to create the examples for Powerpoint and R export. Github does not support .R files so please rename to export-example.R sessionInfo.txt - R session info created by sessionInfo() areaUnderCurve.pdf, areaUnderCurve.pptx - examples created by R export

export-example.txt sessionInfo.txt areaUnderCurve.pdf areaUnderCurve.pptx

TillF commented 6 years ago

Probably related: Filled boxes in boxplots are not correctly filled, when the box boundaries are outside the axis limits. example (modified from https://github.com/davidgohel/ReporteRs/issues/224):

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
tomwenseleers commented 5 years ago

Could you test maybe if https://www.dropbox.com/s/6ikfcq2xobcuezu/export_0.2.2.zip?dl=1 has the same problem? (source code here: https://www.dropbox.com/s/9re7kjtnjj6tjqd/export_0.2.2.tar.gz?dl=1). It's now using the officer package instead of ReporteRs... But pretty sure I can't do anything about this bug in my package, you should post it as a bug in the officer github page instead...

TillF commented 5 years ago

The problem persists. Looking into your code, it seems you are using the function "ph_with_vg_at()" to export the plot. As this belongs to the rvg-package, I posted the issue there: https://github.com/davidgohel/rvg/issues/25

tomwenseleers commented 5 years ago

Ha thanks - yes, I think this bug should be fixed there...