我有两个堆叠的条形图,一个用于输入另一个用于输出。
但是我想在一个空间中绘制这两个图。
我附上了样本。
请帮帮我!!谢谢!!
gr_out <- read.csv("graph_out.csv",header=TRUE, sep=",")
library(ggplot2)
library(reshape2)
gr_out.metlt<-melt(gr_out)
head(gr_out.metlt)
gr_out.metlt$DMU.Name <- factor(gr_out.metlt$DMU.Name, levels = gr_out$DMU.Name)
q <- ggplot(gr_out.metlt, aes(x = DMU.Name, y = value),add=TRUE)
q + geom_bar(aes(fill = variable), stat = "identity") + theme_bw() +
theme(axis.text.x = element_text(angle=60, hjust=1),panel.grid.major = element_blank(), panel.grid.minor = element_blank())+
ylab("Cummulative ratio") + xlab("Station") + scale_fill_brewer(palette = "Paired")
##graph
gr_in <- read.csv("graph_in.csv",header=TRUE, sep=",")
library(ggplot2)
library(reshape2)
gr_in.metlt<-melt(gr_in)
head(gr_in.metlt)
gr_in.metlt$DMU.Name <- factor(gr_in.metlt$DMU.Name, levels = gr_in$DMU.Name)
p <- ggplot(gr_in.metlt, aes(x = DMU.Name, y = value))
p + geom_bar(aes(fill = variable), stat = "identity") + theme_bw() +
theme(axis.text.x = element_text(angle=60, hjust=1),panel.grid.major = element_blank(), panel.grid.minor = element_blank())+
ylim(c(0.0, 8.0)) + ylab("Cummulative ratio") + xlab("Station")+ scale_fill_brewer(palette = "Paired")
这就是我想要实现的目标