-1

Let's say that having the following data:

                    Journey_category Perc_25 Perc_50  Perc_75 Perc_90 Perc_95
1         Petrol - Urban - 0 - 0,2 l  0,1103  0,5158   3,9672  15,304   23,20
2    Petrol - ExtraUrban - 0 - 0,2 l  0,0737  0,3562   3,5155  14,098   21,07
3       Petrol - HighWay - 0 - 0,2 l 40,5790 49,9807 117,5530 189,179  213,79

I want to plot it as a stacked column using ggplot for representing percentiles.

Something linke this:

enter image description here

Any tips?

PD. I know values in the graph don't match, it's only a draft.

Axeman
  • 32,068
  • 8
  • 81
  • 94
Gerard.Ill
  • 31
  • 3
  • Possible duplicate of [Create Stacked percent barplot in R](http://stackoverflow.com/questions/9563368/create-stacked-percent-barplot-in-r) – Axeman Sep 12 '16 at 07:16
  • Thank you, but I think it is not the same case. I have values of percentiles, that issue is for representing basically a pie chart but in bars, representing percentages, not quantities corresponding to specific percentiles. – Gerard.Ill Sep 12 '16 at 07:33
  • 1
    Ok then, can you show us what you have tried so far, and where it is going wrong? – Axeman Sep 12 '16 at 07:38

1 Answers1

0

I found a way to do it:

p <- ggplot(dat_quant, na.rm = T)
p <- p + ggtitle("Idle hours after journey vs charging time needed")
p <- p + labs(x = "Journey category", y = "Idle time after journey (h)")
p <- p + geom_bar(stat = "identity",  aes(x = Journey_category, y = Perc_95, fill = "Perc_95"))
p <- p + geom_bar(stat = "identity",  aes(x = Journey_category, y = Perc_90, fill = "Perc_90"))
p <- p + geom_bar(stat = "identity",  aes(x = Journey_category, y = Perc_75, fill = "Perc_75"))
p <- p + geom_bar(stat = "identity",  aes(x = Journey_category, y = Perc_50, fill = "Perc_50"))
p <- p + geom_bar(stat = "identity",  aes(x = Journey_category, y = Perc_25, fill = "Perc_25"))
Gerard.Ill
  • 31
  • 3