Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/74.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R 在ggplot2中添加自定义间隙_R_Ggplot2 - Fatal编程技术网

R 在ggplot2中添加自定义间隙

R 在ggplot2中添加自定义间隙,r,ggplot2,R,Ggplot2,我有两个独立年份前5个月的数据,以堆叠条形图显示。现在看起来是这样的 我用这个密码到达了我现在的位置 ggplot(data=total_arr2, aes(fill=type, y=flights, x=period, group=year)) + geom_bar(position="fill", stat="identity") + ggtitle("Arrivals by period, type stacked propo

我有两个独立年份前5个月的数据,以堆叠条形图显示。现在看起来是这样的

我用这个密码到达了我现在的位置

ggplot(data=total_arr2, aes(fill=type, y=flights, x=period, group=year)) + 
  geom_bar(position="fill", stat="identity") + 
  ggtitle("Arrivals by period, type stacked proportions") +
  scale_y_continuous(labels = scales::percent)
我想添加一个自定义间隙,将2019年案例与2020年案例分开,这样每年前5个月的趋势可以并排比较,但我想保持它们在同一个图表上


有没有一个相对简单的方法可以做到这一点(总共使用R大约3周,所以这是一个陡峭的学习曲线!!)

一年一个方面
+facet_wrap(~year)
你的程序应该产生你想要的,如果
year=c(201920119201920202020202020020020020)
在你发布之前,搜索网站以确保你的问题没有得到回答1.总结问题2.提供详细信息和任何研究3.适当时,描述一下你尝试了什么?回答你的问题吗?