2

I have data for the first 5 months of 2 separate years presented in a stacked bar plot. Currently it looks like this

current graphical output

I've used this code to get to where I am

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)

I want to add a custom gap to separate the 2019 cases from the 2020 cases so that the trends in the first 5 months of each year can be compared side by side, but I want to keep them on the same graph.

Is there a relatively easy way to do this (been using R for about 3 weeks in total, so it's a steep learning curve!!)

Z.Lin
  • 28,055
  • 6
  • 54
  • 94
Steve_MD
  • 21
  • 1
  • 1
    Facet by year? `+ facet_wrap(~year)` – stefan Aug 02 '20 at 08:50
  • Your program should produce what you want, if `year=c(2019,2019,2019,2019,2019,2020,2020,2020,2020,2020)` – YBS Aug 02 '20 at 10:48
  • Before you post, search the site to make sure your question hasn’t been answered 1.Summarize the problem 2.Provide details and any research 3.When appropriate, describe what you’ve tried – Hakimeh Mordadi Aug 02 '20 at 13:00
  • Does this answer your question? [ggplot2 - bar plot with both stack and dodge](https://stackoverflow.com/questions/12715635/ggplot2-bar-plot-with-both-stack-and-dodge) – tjebo Aug 03 '20 at 09:10

0 Answers0