Home > Blockchain >  How to plot skewed and normal data in r
How to plot skewed and normal data in r

Time:11-13

Using hypothetical data I want to generate these three plots in one plot. enter image description here

I wonder how I can do it. Is it possible to do it using ggplot2 or fGarch packages?

CodePudding user response:

Here an approach with ggplot2

library("ggplot2")

x <- 0:100
y <- c(dnorm(x, mean=50, sd=10), 
       dlnorm(x, meanlog=3, sdlog=.7), 
       dlnorm(100-x, meanlog=3, sdlog=.7))

df <- data.frame(
  x=x,
  y=y,
  type=rep(c("normal", "right skewed", "left skewed"), each=101)
)

ggplot(df, aes(x, y, color=type))   geom_line()
     

Skewness

  • Related