gpt4 book ai didi

r - 使用 savePlot 另存为 pdf 时图例被截断

转载 作者:行者123 更新时间:2023-12-04 11:42:13 26 4
gpt4 key购买 nike

我正在使用 savePlot 以多种格式保存图表。我的 pdf 格式有问题:我的图例在 pdf 文件中被截断,但在 R 图形窗口中没有。我在 Windows 7 上。这是一个小示例,显示图例在屏幕上看起来很棒:

win.graph(width=4.375,height=2.8)
par(bty="l",las=1,lwd=1,cex=0.7,oma = c(1, 1, 0, 1), mar = c(3, 4, 3.5, 5))
plot(1:10,type="l")
legend.names <-c("Dividend yield (L)","Core CPI (L)",
"Dividend yield - core CPI spread (R)")
legend("bottomright", legend=legend.names, lwd=1, cex=0.7, col =1:3,lty=1:3)

但是当我尝试将图表另存为 pdf 时,图例被截断了。最后的'(R)'不完整。

savePlot(filename = paste("c:/out.pdf",sep=""), type ="pdf")

enter image description here

最佳答案

一种解决方案是直接打印到 pdf() 设备中,而不是通过 Windows 设备打印:

pdf(width=4.375, height=2.8, file = "out.pdf")

par(bty="l",las=1,lwd=1,cex=0.7,oma = c(1, 1, 0, 1), mar = c(3, 4, 3.5, 5))
plot(1:10,type="l")
legend.names <-c("Dividend yield (L)","Core CPI (L)",
"Dividend yield - core CPI spread (R)")
legend("bottomright", legend=legend.names, lwd=1, cex=0.7, col =1:3,lty=1:3)

dev.off()

关于r - 使用 savePlot 另存为 pdf 时图例被截断,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9400194/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com