在this question中,我的当前问题已由this question回答;但是建议的代码对我来说还远远不够。这些图表需要适合科学出版,因此yaxs = "i"
和xaxs = "i"
的效果不适合我需要制作的内容。
第二个链接中显示的图表看起来不错,可以完全满足我的工作要求,但是当我对不以0开始的数据使用类似的代码时:
matplot(times, cbind(a, b, c),
pch = 1,
col = c("red", "blue", "green"),
lty = c(1, 1, 1),
xlab = "Time (s)",
ylab = "Flourescense Yield (RFU)",
main = "test",
xlim = c(0 , max(times)),
ylim = c(min(a, b, c) - 0.1* min(a, b, c), max(a, b, c) + 0.1* max(a, b, c)),
axes = FALSE)
axis(1, pos = 0, at = 0: round(times))
axis(2, pos = 0, at = round(min(a, b, c)): round(max(a, b, c)))
legend("topright", y =NULL, c("Biocomposite 1", "Biocomposite 2", "Biocomposite 3"),
text.col = c("red", "blue", "green"))
我得到以下图表:
我简化了代码,所以我不使用实际数据,而是使用以下对象:
a <- sample(1:100, 10, replace = TRUE)
b <- sample(1:100, 10, replace = TRUE)
c <- sample(1:100, 10, replace = TRUE)
times <- c(0:9)
我想让轴在(0,6)处交叉,水平刻度线以5的倍数递增。
任何有关排序的帮助都很棒!
答案 0 :(得分:0)
以下任何一项都可以满足您的要求吗?
方法1:带有框的规则轴(xaxs ='r')?
dev.new()
par(xaxs="r", yaxs="r")
plot(times, a, pch=1, col="red", axes=F, xlab=NA, ylab=NA)
axis(side=1, at=times)
mtext("Times (s)", side=1, line=2.5)
axis(side=2, at=seq(0,100,10))
mtext("Flourescense Yield", side=2, line=2.5)
points(times, b, col="blue")
box()
方法2:或更紧的轴(xaxs ='i'),但是x和y的限制略微夸张,并带有一个框?
dev.new()
par(xaxs="i", yaxs="i")
plot(times, a, pch=1, col="red", axes=F, xlab=NA, ylab=NA,
xlim=c(-.5,9.5), ylim=c(-2,102))
axis(side=1, at=times)
mtext("Times (s)", side=1, line=2.5)
axis(side=2, at=seq(0,100,10))
mtext("Flourescense Yield", side=2, line=2.5)
points(times, b, col="blue")
box()