这个阴谋的主要目标是使A
和B
之间的比较三组,但我希望有one
,two
,并且除了他们three
,也是如此。使用下面的代码,我可以创建一个分组的barplot,这几乎是我想要的。但是由于传说非常难看,我需要在它下面的每个栏的名称。Labling酒吧分组barplot在ggplot
我该怎么办?
m.names <- c("A1","B1","one","A2","B2","two","A3","B3","three")
m.group <- c(1,1,1,2,2,2,3,3,3)
m.value <- c(5,10,1,20,15,2,10,20,3)
df <- data.frame(m.names, m.group, m.value)
df
ggplot(df, aes(x = m.group, y = m.value)) +
geom_bar(aes(fill = m.names), position = "dodge", stat = "identity") +
scale_fill_manual(values=c("gray75", "gray75","gray75", "gray40","gray40","gray40", "blue", "red", "green"))
谢谢,这几乎是我想要的,是不是很容易摆脱组名,并将条形标签放在图下方? – havij
如果这是你想要的,你可能会更好地看着Z Lin的回答(+我的评论)。 – Marius