I have a dataframe with shares in percent,columns representing different items, rows the respective share of interviewees answering in different categories. I want to produce a stacked barchart.
library(ggplot2)
library(reshape2)
test<-data.frame(i1=c(16,40,26,18),
i2=c(17,46,27,10),
i3=c(23,43,24,10),
i4=c(19,25,20,36))
rownames(test)<-c("very i.","i.","less i.","not i.")
test.m<-melt(test)
ggplot(test.m, aes(x=variable, y=value, fill=value)) +
geom_bar(position="stack", stat="identity")
Looks o.k., but I want
a) center the bars: positive answers (very i. and i) up and the bottom two classes (less i. and not i.) down.
b) each category (very i, i, less i, not i,) having the same colour.
Any help would be much appreciated.
See Question&Answers more detail:os