I want to plot 3 curves in the same plot:
curve(dweibull(x, shape=0.5, scale = 1), from=0, to=5)
par(new=TRUE)
curve(dweibull(x, shape=1, scale = 1), from=0, to=5)
par(new=TRUE)
curve(dweibull(x, shape=1.5, scale = 1), from=0, to=5)
I am aware that using par(new=TRUE)
will plot the curves in the same plot but I had three y-axes smeared together, as below:
How do I get one clear y-axis?
CodePudding user response:
A ggplot
option using geom_function
like this:
library(ggplot2)
ggplot()
geom_function(fun = function(x) sin(x))
geom_function(fun = function(x) cos(x))
geom_function(fun = function(x) 3*x)
labs(x = "x", y = "y")
theme_bw()