I create a plot from data in R using ggplot2. When saving the ggplot object to a png file, the plot looks exactly as it should (see picture). When saving the same ggplot object to a pdf, all text corrupts. Anyone knows a solution?
 data <- data.frame(matrix(nrow=50, ncol=3)) # Generate sample data
 colnames(data) <- c("LUT", "Climate", "parameter") 
 data$LUT <- c("EM", "EP", "IM", "OF", "CF")
 data$Climate <- rep(c("amb", "fut"), each=5)
 for(i in 1:25){
 data$parameter[data$Climate=="amb"][i] <- sample(10:110,1)
 data$parameter[data$Climate=="fut"][i] <- sample(0:100,1)
 }
 data
 
 
 test_figure <- ggplot(aes(y=parameter, x=LUT, color=Climate), data=data)+ # Generate ggplot object
 geom_point()+
 scale_colour_manual(values=c("amb" = "#007089", "fut" = "#60c3d9"))+
 stat_summary(
 geom = "point",
 fun.y = "mean",
size = 5,
shape = 17)+
stat_summary(fun.data = mean_se, geom = "errorbar")+ # add errorbar
ylab("test_lab")+
theme(text = element_text(size = 22),
plot.title = element_text(size=25),
axis.text.y = element_text(size=18),
axis.text.x = element_text(size=18),
axis.title.y=element_text(size=17))
ggsave("test.figure.png", test_figure) # Save as png / pdf
pdf("test_figure.pdf")
print(test_figure)
dev.off()
 
    