R ggplot combining two graphs

I am trying to combine two different ggplot (line graph) into one x and y axis. However, one graph has y range of -0.5 to 0.5 and another graph has y range of 50 to 110.

I would like to ignore y ranges of two graphs and just want to combine them into one graph which show plot of two different graph clearly.

p1 <- ggplot(data2, aes(x = t, y = ECG)) + geom_line() + xlim(c(0,3)) + ylim(c(-1,1))
p2 <- p1 + geom_line(aes(y = NIBP))

Hi, thanks for providing some code - however, this is not a reproducible example since you do not provide the dataset data2. See here for instructions.

You can display two y axes with a transformation. Basically, make both the same range and use scale_y_continuous(sex.axis = dup_axis(trans = )). You can use ?dup_axis to look at examples how to use it.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.