Monday 12 November 2018

r - Draw more than one function curves in the same plot

Use the points function. It has the same exact syntax as plot.


So, for instance:


fun1 <- function(x) sin(cos(x)*exp(-x/2))
x <- seq(0, 2*pi, 0.01)
plot (x, fun1(x), type="l", col="blue", ylim=c(-0.8, 0.8))
points (x, -fun1(x), type="l", col="red")

Note that plot parameters like ylim, xlim, titles and such are only used from the first plot call.

No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...