Creating boxplots in rstudio using tidyverse(ggplot2) and gg.gap with flipped coordinates

I have three columns of data. The first column is the categories of hearing dysfunctions, the second column is the number of adult cases as reported by different hearing clinics for all 7 categories, and the third column is the number of child cases as reported by different hearing clinics for 2 of the 7 categories. I created boxplots in tidyverse using ggplot2 for each dataset. I needed to use gg.gap to change the layout of the y-axis to include gaps and make the data easier to view.

This is the code I used and it works for a normal x-horizontal, y-vertical boxplot.
''''r
p <-ggplot(data=AVBoxplots,aes(HearingDysfunction,AdultCases))+geom_boxplot() + ylab("Adult Cases") + theme_classic()

gg.gap(plot=p, segments=list(c(10.5,12),c(55,150)), tick_width=c(1,10,5), ylim=c(0,160))
'''''R

The code works well. The labels on the x-axis are all bunched together. Some of the labels are long so they would look much better with the coordinates flipped (i.e., I would like to rotate the boxplots so that the x-axis is on the vertical and the y-axis, with the gaps in place, is on the horizontal axis. When I try to plot using coord_flip(), the boxplots remain vertical but split into two halves with 1 figure on the left and two figures on the right.

Any help is greatly appreciated.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.