[英]starting the y-axis at a minimum value, the x-axes at 0, and making them intersect using matplot() in R
在这个问题上说我现在的问题被这个问题回答了; 但是建议的代码对我来说还远远不够。 这些图表需要适合科学出版,因此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的倍数递增。
排序方面的任何帮助都将很棒!
以下任何一项都可以满足您的要求?
方法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()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.