[datatable-help] Print percentage labels SEPARATELY based on groups [ggplot]
snowwings
snowwings.xbc at gmail.com
Fri Jan 8 23:03:42 CET 2016
I have a data set have two groups, and used ggplot to plot histogram. I tried
to print the percentages in each group but not the percentage of the total.
ggplot(data.frame(general), aes(x = general$Severity, fill = Organization))
+ geom_bar(position = "dodge") + stat_bin(aes(y=..count.., label =
paste(..count.., sprintf("%.02f %%",
..count../sum(..count..)*100))),geom="text", vjust=-.5,size=3,position =
position_dodge(width = 0.8)) +
scale_x_discrete(limits=levels(general$Severity)[1:8]) + theme(axis.text.x =
element_text(angle = 15, hjust = 1)) + xlab("Severity") +
scale_fill_manual(values=c("royalblue2", rgb(212, 179, 125,
maxColorValue=255)))
<http://r.789695.n4.nabble.com/file/n4716290/1.png>
Howeve, I want show the percentages in the table below:
<http://r.789695.n4.nabble.com/file/n4716290/2.png>
And I don't want to show the "NA" in the plot. It feels like that I should
change the label sentence. What kind of code should I use?
--
View this message in context: http://r.789695.n4.nabble.com/Print-percentage-labels-SEPARATELY-based-on-groups-ggplot-tp4716290.html
Sent from the datatable-help mailing list archive at Nabble.com.
More information about the datatable-help
mailing list