mean_sim <- 10
std_sim <- 5
lcb <- ((mean_sim - (3 * std_sim)) - 5)
ucb <- (((2 * mean_sim) + (3 * (2 * std_sim))) + 5)
u <- seq(from = lcb,
to = ucb,
length.out = 1e+5)
v1 <- dnorm(x = u,
mean = mean_sim,
sd = std_sim)
v2 <- dnorm(x = u,
mean = (2 * mean_sim),
sd = (2 * std_sim))
matplot(x = u,
y = cbind(v1, v2),
type = "l",
lty = 1,
col = c("red", "blue"),
xlab = "values",
ylab = "densities",
main = "base Solution 1")
legend(x = "topright",
legend = paste("Distbn.", 1:2),
col = c("red", "blue"),
lty = 1)

plot.function(x = function(t) dnorm(x = t, mean = mean_sim, sd = std_sim),
from = -10,
to = 55,
col = "red",
xlab = "values",
ylab = "densities",
main = "base solution 2")
plot.function(x = function(t) dnorm(x = t, mean = (2 * mean_sim), sd = (2 * std_sim)),
from = -10,
to = 55,
col = "blue",
add = TRUE)
legend(x = "topright",
legend = paste("Distbn.", 1:2),
col = c("red", "blue"),
lty = 1)
library(ggplot2)

ggplot(data = data.frame(u = c(lcb, ucb)),
mapping = aes(x = u)) +
stat_function(mapping = aes(colour = "Distbn. 1"),
fun = dnorm,
args = list(mean = mean_sim,
sd = std_sim)) +
stat_function(mapping = aes(colour = "Distbn. 2"),
fun = dnorm,
args = list(mean = (2 * mean_sim),
sd = (2 * std_sim))) +
scale_colour_manual(values = c("red", "blue")) +
labs(x = "values",
y = "densities",
title = "ggplot solution")

Created on 2019-07-12 by the reprex package (v0.3.0)
Hope this helps.