meitei
1
How can I replicate the folllowing plot using ggplot?
library(kde1d)
set.seed(100)
x=sample(1000,100)
fit <- kde1d(x,bw = 92)
plot(NULL, xlim = c(0, 1000), ylim = c(0, 1), axes = TRUE,
xlab = "Value",
ylab = expression("Probability"))
curve(pkde1d(x, fit),
add = TRUE, col = "black", lwd = 1.5)
Thank you
FJCC
2
Does this get you what you want? I do not have the kde1d package to test the code.
library(kde1d)
library(ggplot2)
set.seed(100)
x=sample(1000,100)
fit <- kde1d(x,bw = 92)
Y <- pkde1d(x, fit)
DAT <- data.frame(X = x, Y = Y)
ggplot(DAT, aes(X, Y)) + geom_line(color = "black", size = 1.5) +
xlim(0,1000) + ylim(0,1) +
labs(x = "Value", y = "Probability")
1 Like
system
Closed
3
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.
If you have a query related to it or one of the replies, start a new topic and refer back with a link.