I'm using R package mschart
to populate MS chart into PPT. I have added add multiple charts into one slide using the function ph_with_chart_at
to define the location of ppt. However, the plot area is too small.
How can I resize the plot?
Example:
here is the sample code, when you open the ppt, I want to enlarge the size the plot area or control the space between axis y 40%, 50%,60%...
library(officer)
library(mschart)
library(dplyr)
data <- data.frame(Name=c("a","a","a","a","b","b","b","b"),
wave_id=c("2017Q1","2017Q2","2017Q3","2017Q4","2017Q1","2017Q2","2017Q3","2017Q4"),
pct=c(0.68,0.71,0.70,0.72,0.57,0.57,0.57,0.58))
data1 <- data%>%
ms_linechart(x="wave_id",y="pct",group="Name")%>%
chart_labels(title=NULL,xlab="",ylab="")%>%
chart_ax_y(limit_min = 0.4,limit=0.8,
num_fmt='0%%',major_tick_mark="none",minor_tick_mark="none")
data1_theme<- mschart_theme(
legend_text = fp_text(font.size=8),
axis_text = fp_text(font.size=8),
legend_position = "r",
grid_major_line=fp_border(width=))
pptsdata1 <- set_theme(data1,data1_theme)
doc <- read_pptx()
doc <-doc%>%
add_slide(layout = "Title and Content", master = "Office Theme")%>%
ph_with_chart_at(chart=pptsdata1,left=1,top=2,height=1.55,width=8)
print(doc, target = "my_plot.pptx")
If you look at the outputted graph, you can see that the plot only takes up a small amount of the plot area, with a lot of white space left around the plot: