tomwenseleers / export

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

Trouble when saving ggplot graph with superscripts to pptx #7

Closed annaabrahao closed 7 years ago

annaabrahao commented 7 years ago

Hi, I get the following error when trying to save the plot: Error in grid.Call.graphics(L_text, as.graphicsAnnot(x$label), x$x, x$y, : Metric information not available for this family/device I can save it with ggsave, and plot it on the screen, but can't export to ppt.

library(ggplot2) library(export)

P<-c(rep(0,times=18),rep(0.5,times=18),rep(5,times=18),rep(50,times=18)) P<-as.factor(P) N<-rep(c(rep(10,times=6),rep(30,times=6),rep(50,times=6)), times=4) N<-as.factor(N) set.seed(42) Y<-runif(n=72)*10

dat<-data.frame(P=P,N=N,Y=Y)

test<-ggplot(dat, aes(x=P, y=Y)) + geom_boxplot(position="dodge", aes(fill=N))+ ylab(expression(paste('Measurement (µmol ',g^{-1},' root FW)')))+ xlab(expression(paste('P supply (mg ',kg^{-1},' soil)')))+ labs(fill=expression(paste('N (mg ',kg^{-1},')'))) test

graph2ppt(test, file="test.pptx")

I hope you can help!

Cheers, Anna

sessionInfo() R version 3.3.3 (2017-03-06) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 7 x64 (build 7601) Service Pack 1

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 methods
[7] base

other attached packages: [1] gdtools_0.1.4 export_0.2.1 ggplot2_2.2.1 rJava_0.9-8

loaded via a namespace (and not attached): [1] Rcpp_0.12.10 knitr_1.14 xml2_1.1.1
[4] magrittr_1.5 ReporteRsjars_0.0.2 munsell_0.4.3
[7] xtable_1.8-2 colorspace_1.2-6 R6_2.1.2
[10] plyr_1.8.4 dplyr_0.5.0 tools_3.3.3
[13] grid_3.3.3 gtable_0.2.0 png_0.1-7
[16] rvg_0.1.3.9000 R.oo_1.21.0 DBI_0.4-1
[19] htmltools_0.3.5 rgl_0.97.0 lazyeval_0.2.0
[22] assertthat_0.1 digest_0.6.9 tibble_1.1
[25] shiny_1.0.0 tidyr_0.6.1 officer_0.1.1
[28] purrr_0.2.2 htmlwidgets_0.8 ReporteRs_0.8.8
[31] base64enc_0.1-3 R.utils_2.5.0 rtable_0.1.5
[34] mime_0.5 labeling_0.3 scales_0.4.1
[37] R.methodsS3_1.7.1 jsonlite_1.1 httpuv_1.3.3