R绘图条在网格中消失。排列/Plot\u网格

R绘图条在网格中消失。排列/Plot\u网格,r,ggplot2,bar-chart,gridextra,cowplot,R,Ggplot2,Bar Chart,Gridextra,Cowplot,当我合并多个绘图时,我的绘图中的栏消失了,这是一个问题 以下是我使用的代码: station<-c("Eins", "Zwei", "Drei","Vier") x1<-c(200, 185, 165,180) x2<-c(185,150,148,25) x3<-c(156,125,141,36) test.data<-data.frame(station,x1,x2,x3) pl

当我合并多个绘图时,我的绘图中的栏消失了,这是一个问题

以下是我使用的代码:

station<-c("Eins", "Zwei", "Drei","Vier")
x1<-c(200, 185, 165,180)
x2<-c(185,150,148,25)
x3<-c(156,125,141,36)

test.data<-data.frame(station,x1,x2,x3)


plot_sof<-ggplot(test.data, aes(x=station, y=x1))
plot_sof + geom_bar(stat="identity",na.rm=TRUE)

plot_sof_1<-ggplot(test.data, aes(x=station, y=x2))
plot_sof_1+geom_bar(stat = "identity",na.rm=TRUE)

plot_sof_2<-ggplot(test.data, aes(x=station, y=x3))
plot_sof_2+geom_bar(stat = "identity",na.rm=TRUE)

plot_grid(plot_sof, plot_sof_1, plot_sof_2, labels=c("x1", "x2", "x3"))

grid.arrange(plot_sof, plot_sof_1, plot_sof_2, ncol=1)```

站尝试此操作,您必须将新几何图形指定给对象:

#Code
plot_sof<-ggplot(test.data, aes(x=station, y=x1))
plot_sof <-plot_sof + geom_bar(stat="identity",na.rm=TRUE)

plot_sof_1<-ggplot(test.data, aes(x=station, y=x2))
plot_sof_1 <- plot_sof_1+geom_bar(stat = "identity",na.rm=TRUE)

plot_sof_2<-ggplot(test.data, aes(x=station, y=x3))
plot_sof_2 <- plot_sof_2+geom_bar(stat = "identity",na.rm=TRUE)

plot_grid(plot_sof, plot_sof_1, plot_sof_2, labels=c("x1", "x2", "x3"))

grid.arrange(plot_sof, plot_sof_1, plot_sof_2, ncol=1)
#代码

谢谢,这就是解决办法。很明显,如果我在这个愚蠢的问题上浪费了你的时间,我很抱歉。@Andréu 1090很高兴能帮助你,而且
ggplot2
的学习曲线有这样的东西,但它们帮助你成为一个更好的编码者:)