5
I got the following graph with the curve function:
f1 <- function(x){x^4 - 6*(x^2)}
curve(f1, xlim = c(-3, 3), ylim= c(-10, 5), ylab = expression(x^4 - 6*(x^2)))
However, I would like to use the ggplot2 package to play this same chart (with the same limits of x and y). I managed to develop this simple code:
x <- c(-4:4)
y <- c(x^4 - 6*(x^2))
ggplot() +
geom_line(aes(x=x, y=y))
But I would need to smooth the curve and set the limits of x and y. How can I get a graph similar to the first using ggplot?