【发布时间】:2015-01-23 18:30:43
【问题描述】:
我无法打开使用 ggplot 创建的 pdf。当我尝试在 Adobe 中打开文件时,我收到一条错误消息,指出我无法打开该文件,因为它仍在另一个应用程序中打开。我 am 使用 dev.off() 所以我不知道为什么我无法打开 pdf...
这是我的图形参数和变量:
stepheights=c(1.3, 2.6, 3.9, 5.2, 6.6, 7.9, 9.2, 10.5, 11.8, 13.1, 14.4, 15.7, 17.1, 18.4, 19.7, 21.0, 22.3, 23.6, 24.9, 26.2, 27.6, 28.9, 30.2, 31.5, 32.8, 34.1)
Qs=c(2.0381420, NaN, 2.9921695, NaN, 6.9614420, 109.6719419, 80.7758644, NaN, 7.9477900, 18.3467407, 46.6796869, 117.7829841, 122.2436537, 6.8123483, 26.6823085, 74.5536880, 0.0421594, 92.1911593, 42.8689561, 18.5230607, 23.0842770, 132.5477074, 50.2996339, 3.1371337, NaN,NaN)
这两个变量都在数据框 VelocityData 中
#create our graphing parameters using ggplot
downstream_QS<-ggplot(data=VelocityData, aes(x=stepheights, y=Qs))+geom_point() +
stat_smooth(method="lm",formula=y~log(x), fill="red") +
scale_x_continuous(breaks=x) +
labs(x="Distance Downstream (cm)", y="Sediment Transport") +
ggtitle("Sediment Transport Downstream of a Backward-Facing Step as Calculated from Near-bed Shear Stress") +
theme(plot.title=element_text(family="Palatino", face="bold", size=24),
axis.title.y=element_text(family="Palatino", face="bold",
size=14), axis.title.x=element_text(family="Palatino", face="bold", size=14),
axis.text.y=element_text(family="Palatino", face="bold", size=10),
axis.text.x=element_text(family="Palatino", face="bold", size=10))
pdf(paste('C:/Users/kcpotter/Desktop/Flume/BS Experiments/Step/ADV Qs Profile.pdf'), width=8, height=4)
print(downstream_QS)
dev.off()
【问题讨论】:
-
您可以删除文件并重试吗?这听起来不像是与 R 相关的错误。
-
删除文件然后使用 ggsave() 解决了问题。