高分辨率绘制多行代码

时间:2018-12-11 08:39:25

标签: r plot graphics resolution

我已经使用几个命令在R中制作了一个条形图。现在,我想以高分辨率保存该图。为此,我使用了tiff()函数。但是,只有第一个命令保存在tiff中。在那儿: a)一种将多个代码行写入一个文件的方法?要么 b)一种将倒数第二个命令包含在第一个命令中的方法,以便将所有内容写入到tiff中?

我使用的代码是(带有示例编号):

Means <- array(NA, dim=c(2,5))
Means[1,] <- c(9, 7, 4, 2, 3)
Means[2,] <- c(8,4,3,1,5)
SE <- array(NA, dim=c(2,5))
SE[1,] <- c(0.5, 0.4, 0.6, 0.3, 0.2)
SE[2,] <- c(0.4, 0.5, 0.3, 0.1, 0.25)

Top <- max(Means) + max(SE)
tiff("Example.tiff", width = 4, height = 4, units = 'in', res = 300)

BarCenters <- barplot(height = Means,
                   beside = TRUE, las = 1,
                   ylim = c(0, 12),
                   cex.names = 1,
                   col=c("gray35","gray85"),
                   main = "",
                   ylab = "",
                   cex.lab=1.1,
                   border = "black", axes = TRUE,
                   legend.text = TRUE,
                   args.legend = list(x = "topright", cex = .85))
title(ylab="Example", line=2.5, cex.lab=1.2)

segments(BarCenters, Means, BarCenters, Means + SE, lwd = 1.5)

arrows(BarCenters, Means, BarCenters, Means + SE, lwd = 1.5, angle = 90,     
code = 3, length = 0.05)

text(BarCenters, Means + SE, labels = Means, pos = 3, cex = .75)

0 个答案:

没有答案