在最小值开始y轴中,x轴为0,并使其交叉使用matplot()中的R

问题描述 投票:0回答:1

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"))

我得到如下图:

enter image description here

我已经简化了代码,所以我不会用我的实际数据,而我使用的下列对象:

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的倍数递增。

与此排序任何帮助将是巨大的!

r axes intercept
1个回答
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()
© www.soinside.com 2019 - 2024. All rights reserved.