You would set this in the chart theme, not in chart_data_labels
. The manner in which you document these for mschart
is extremely similar to how it comes together for ggplot2
.
For example, I could identify the styles in the theme as I did in this example.
library(officer)
library(mschart)
# define special theme requirements
mytheme <- mschart_theme(axis_title = fp_text(color = "white",
shading.color = "#767171",
font.size = 24,
bold = TRUE))
# create bar chart
bc <- ms_barchart(data = mtcars %>%
mutate(cyl = as.factor(cyl)),
x = "cyl", y = "mpg")
# apply the theme
bc <- set_theme(bc, mytheme)
# update the labels
bc <- chart_labels(bc, title = "Cars",
xlab = "Engine Cylinders",
ylab = "Miles per Gallon")
# create the pptx
mp <- read_pptx()
# create the slide
mp <- add_slide(mp, layout = "Title and Content", master = "Office Theme")
# add content to the slide
mp <- ph_with(mp, bc, location = ph_location_fullsize())
# create temp file and save pptx to temp file
fo <- tempfile(fileext = ".pptx")
print(mp, target = fo)
