2
votes

I am new to ggplot and I have some questions. I hope someone can help me out in making the plot I want to make.

How can I plot quantiles that were previously calculated, with ggplot2?

X=runif(34,min=4, max=89)

quantiles.X=quantile(X,probs=c(.01,.03,.05,.1,.15,.20,.50,.70,.80,.90,.95))
> quantiles.X
      1%        3%        5%       10%       15%       20%       50%       70%       80%       90%       95%

5.292614  5.813105  9.509620 20.036279 25.542286 28.704292 49.796086 68.832996 76.725968 77.947276 80.549077

edited

I was aiming for the display of the quantiles was a form of histogram style or line. Maybe to plot a line for each quantile over the point data will be more communicative/useful.

1
what sort of graph would you like? histogram? line? etc... - Seb
And what is the message you want the plot to convey? - Paul Hiemstra
both histogram and line. however line would allow me to save on the number of plots I will be using, e.g. I could plot the percentile/quantile lines over the point data. - Gago-Silva

1 Answers

3
votes

You could something along these lines:

X=runif(34,min=4, max=89)
p = c(.01,.03,.05,.1,.15,.20,.50,.70,.80,.90,.95)
dat = data.frame(q = quantile(X, probs = p),
                 prob = p)

And then plot using ggplot2:

ggplot(aes(x = prob, y = q), data = dat) + geom_line()