简体   繁体   English

两个y轴图不重叠

[英]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. 我试图制作一个到y轴的图形,以使每个y轴的值都在框的中间开始,这样我绘制的2条线就不会重叠。 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. 我已经搜索了一段时间,但是还没有找到用R中的基本XY图形执行此操作的任何方法,并且我在图形中添加了其他内容,因此我不想使用其他程序包执行此操作。

在此处输入图片说明

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. 考虑到图形,我需要使顶部的图形与底部的图形“合并”,并且顶部图形的左侧y轴的值向右更改,但从中间开始,这样线条就不会重叠。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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