How can I draw two graphs in one plot?

Hello, I have a code that draws 2 graphs like following :

plot(seq(-5, 5, 0.05), (1/(1+exp(-seq(-5, 5, 0.05)))), 
     xlab = 'x', ylab = 'y', type='l', main="Cumulative Distribution") 

plot(seq(-5, 5, 0.05), pnorm(seq(-5, 5, 0.05), mean=0, sd=1),  
     xlab = 'x', ylab = 'y', type='l', main="Cumulative Distribution")

I want to merge these, but with different colors, so I can compare two graphs' formation. I guess I can solve this with ggplot2 package, but don't have any idea to go further. I would be appreciate if you tell me a solution.

Is this what you are after?

plot(seq(-5, 5, 0.05), (1/(1+exp(-seq(-5, 5, 0.05)))), 
     xlab = 'x', ylab = 'y', type='l', main="Cumulative Distribution") 

lines(seq(-5, 5, 0.05), pnorm(seq(-5, 5, 0.05), mean=0, sd=1),  
     xlab = 'x', ylab = 'y', type='l', main="Cumulative Distribution",
     col = "red")

Created on 2022-11-30 with reprex v2.0.2

2 Likes

ahh...I thought I have to use some connection like + or something like that...but it wasn't.
this is just an overlapping. Thank you. This is what I exactly wanted

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

If you have a query related to it or one of the replies, start a new topic and refer back with a link.