[英]How to draw two curves in one plot / graph
您可以尝试将lines()
参数添加到现有的 plot 中:
f1 = function(x1){
return (sqrt(64-x1^2))
}
f2 = function(x2){
return (cos(x2) - x2)
}
x <- c(-5:5) # choose your x value range here
y1 <- mapply(FUN = f1,x1 = x) # lets get the y values before plotting
y2 <- mapply(FUN = f2,x2 = x) # lets get the y values before plotting
plot(x,y1, type = "l", col = "red", ylim = c(-5,10))
lines(x, y2, col = "blue", type = "l")
给你这个:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.