0

I am using the ggplot function to plot this kind of graph image

I want to add the specific value of the x-axis as shown in the picture

this is my code :

    quantiles <- quantile(mat,prob = quant)
    x <- as.vector(mat)
    d <- as.data.frame(x=x)
    p <- ggplot(data = d,aes(x=x)) + theme_bw() +
      geom_histogram(aes(y = ..density..), binwidth=0.001,color="black",fill="white") +
      geom_density(aes(x=x, y = ..density..),fill="blue", alpha=0.5, color = 'black')

    x.dens <- density(x)
    df.dens <- data.frame(x = x.dens$x, y = x.dens$y)
    p <- p + geom_area(data = subset(df.dens, x <= quantiles), aes(x=x,y=y),
                       fill = 'green', alpha=0.6)
    print(p)
N.BY
  • 1
  • 2
  • what is `mat`? Have you tried `scale_x_continuous(breaks, ...)`? – oshun Jul 21 '16 at 18:12
  • mat is a matrix of one column of my sample . when you use scale_x_continuous(breaks, ...) you have a percentage not the value ! – N.BY Jul 21 '16 at 19:43

0 Answers0