R 多条图的构造

R 多条图的构造,r,plot,ggplot2,R,Plot,Ggplot2,如何在连接的链接上构造一个类似图的 我不知道如何在ggplot2中放置和移动钢筋 提前感谢您的帮助 为便于数据传输 data <- data.frame(klm=c(1L,2L,3L), year=c(rep(2000,3),rep(2016,3)), Category1=c(c(1313,1057,981),c(1456,1200,1124)), Category2=c(c(1661,1057,981),c(182

如何在连接的链接上构造一个类似图的

我不知道如何在ggplot2中放置和移动钢筋

提前感谢您的帮助

为便于数据传输

data <- data.frame(klm=c(1L,2L,3L),
            year=c(rep(2000,3),rep(2016,3)),
            Category1=c(c(1313,1057,981),c(1456,1200,1124)),
            Category2=c(c(1661,1057,981),c(1827,1444,1400)))


data$klm <- factor(data$klm, levels=1:3, labels=c("Belgium", "Netherlands","Germany"))

data$rok <- factor(data$year,levels=c(2000,2016))




 ggplot(data, aes(x = klm)) 
 + geom_bar(aes(y = Category1[1:3])) 
 + geom_bar(aes(y = Category1[4:6]),position = "dodge") 
 + geom_bar(aes(y = Category2[1:3])) 
 + geom_bar(aes(y = Category2[4:6]),position = "dodge") 

数据将帮助用户在视觉上改进它

data <- data.frame(klm=c(1L,2L,3L),
               year=c(rep(2000,3),rep(2016,3)),
               Category1=c(c(1313,1057,981),c(1456,1200,1124)),
               Category2=c(c(1661,1257,1301),c(1827,1444,1600)))


data$klm <- factor(data$klm, levels=1:3, labels=c("Belgium", "Netherlands","Germany"))

data$year <- factor(data$year,levels=c(2000,2016))

Średnia=
  ggplot(data=data, aes(x=klm, y=Category2, fill=year)) +
  geom_bar(stat="identity", position=position_dodge(),colour="black")+
  scale_fill_manual(values = c("blue", "red"))+
  geom_text(aes(y = Category2,label = format(Category2,big.mark = " ")),position = position_dodge(width = 1),vjust = -0.5, hjust = 0.5, cex = 3)


Średnia+
  geom_bar(data=data, aes(x=klm, y=Category1, fill=year),stat="identity", width = 0.5,position=position_dodge(), colour="black")+
  geom_text(aes(y = Category1,label = format(Category1,big.mark = " ")),position = position_dodge(width = 1),vjust = -0.5, hjust = 0.5, cex = 3)

数据到目前为止您尝试了什么,为什么不奏效您可能正在寻找
position=“dodge”
。如果没有花哨的把戏,你就不可能创造出这样的传奇。ggplot(数据,aes(x=klm))+geom_-bar(aes(y=Category1[1:3]))+geom_-bar(aes(y=Category1[4:6]),position=“dodge”)+geom_-bar(aes(y=Category2[1:3])+geom_-bar(aes(y=Category2[4:6]),position=“dodge我开始,我不知道,请在你的问题中包括代码,而不是在评论中。您可以使用。谢谢