a)我想创建一个多个y为x的条形图。
df<-data.frame(x=rep(c("x1","x2","x3","x4"),each=6),
Legend=c("a","b","c","d","e","f"),
y1=c(2843,2843,2843,900,1200,1000,2843,2843,2843,900,1200,1000,2843,2843,2843,900,1200,1000,2843,2843,2843,900,1200,1000),
y2=c(3000,3000,3000,NA,NA,NA,3000,3000,3000,NA,NA,NA,3000,3000,3000,NA,NA,NA,3000,3000,3000,NA,NA,NA))
df2<-melt(df,id=c("x","Legend"))
library(ggplot2)
p <- ggplot(data=df2, aes(x=x,y=value,fill=Legend)) +
geom_bar(stat="identity",position="dodge")
p
现在的问题是我的y1
值x1
和a
似乎没有绘制。只有y2
和a
的{{1}}值可见。我需要每x1
,x1
,x2
和x3
有9个小节。
x4
,x1
,x2
,x3
内的条形码?