简体   繁体   中英

Two y-axis plot without overlapping

I am trying to make a graphic with to y-axis that the values of each y-axis start at the middle of the box so the 2 lines that I am plotting do not overlap. I have search for some time but have not found any way to do that with the basic XY graphics from R and i am adding some other things to the graphic so i don't want to do it with other package.

在此处输入图片说明

With the graphic in mind what I need it that the top one "merges" with the bottom and that the values on the left y-axis of the top graph change to the right but start at the middle, that way the lines wont overlap.

Do you mean something like this?

d1 <- data.frame(x=1:10, y=sin(1:10))
d2 <- data.frame(x=1:10, y=sin(1:10)+10)

plot(rbind(d1,d2), t="n", yaxt="n")
lines(d1)
lines(d2)
axis(2, at=pretty(d1$y))
axis(4, at=pretty(d2$y))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM