I am having trouble with text being slightly shifted vertically in the PPT output compared to what I see onscreen (e.g. the X axis labels touch the X axis tickmarks in the PPT when they don't touch onscreen). Also, the width & height argument appears to be ignored, as my graph is always stretched across the slide, which I don't want here (sorry if that's a silly issue).
Reproducible example:
library(ggplot2)
library(devtools)
devtools::install_github("davidgohel/rvg")
devtools::install_github("davidgohel/officer")
devtools::install_github("davidgohel/gdtools")
library(rvg)
library(gdtools)
plot_data <- data.frame (a = runif (1:20), b = seq (1:20))
x11 (width = 3, height = 3)
z <- ggplot(data = plot_data, mapping = aes (x = a, y = b)) +
geom_point() +
labs(x = "my x-label", y = "my y-label") +
theme(panel.background = element_blank(),
panel.border = element_rect (fill = NA, size = 0.5),
axis.ticks = element_line (color = "black", lineend = "round", size=0.5),
axis.ticks.length = unit (2, "mm"),
axis.text = element_text (color = "black"),
plot.margin = unit(rep (0, 4), "cm"),
text = element_text (size=18,
family="sans",
color = "black")
)
z
library(officer)
doc <- read_pptx()
doc <- add_slide(doc, "Title and Content", "Office Theme")
doc <- ph_with(doc, dml(ggobj = z, width = 3, height = 3), # I get the same output with extra argument fonts = list(sans = "TT Arial")),
location = ph_location_type(type = "body"))
fileout <- "test.pptx"
print(doc, target = fileout)
I am having trouble with text being slightly shifted vertically in the PPT output compared to what I see onscreen (e.g. the X axis labels touch the X axis tickmarks in the PPT when they don't touch onscreen). Also, the width & height argument appears to be ignored, as my graph is always stretched across the slide, which I don't want here (sorry if that's a silly issue). Reproducible example:
test.pptx