【发布时间】:2018-05-09 17:06:02
【问题描述】:
下面的代码应该将下面的图表(带有图表外的图例)导出为 pdf。但是图例没有出现在生成的 pdf 中。但是,如果我只运行没有 pdf 行的代码,则图例会显示在 Rstudio 的绘图查看器中。
pdf(paste("testgraph.pdf", sep=''), paper="a4r", width=10, height=10)
set.seed(1) # just to get the same random numbers
plot(1:30, rnorm(30), pch = 1, lty = 1, type = "o", ylim=c(-2,2), bty='L')
legend("topright", inset=c(-0.3,0),c("group A", "group B"), pch = c(1,2), lty = c(1,2))
dev.off()
【问题讨论】: