I'm trying to plot a multipane figure which displays standard error plots of various biodiversity metrics. I have data from five rivers but I want to display the five rivers independently (currently called in the facet_warp function) but I want to add a sixth graph that plots all data combined as standard error (with this graph being the final graph in the row of 6). I can plot a sixth graph as scatter plot or small SE but not the same format as the other graphs. Any help would be greatly appreciated.

Thanks so much in advance! Code I am using for one metric is below.

sum = summarySE(Summer, 
                measurevar="Feve", 
                groupvars=c("Habitat","River"))

str(sum)

pd = position_dodge(.5)

fig1 <- ggplot(sum, aes(x=Habitat, 
                        y=Feve, 
                        colour = Habitat)) + 
  geom_errorbar(aes(ymin=Feve-se, 
                    ymax=Feve+se), 
                width=.2, size=0.7, position=pd) +
  geom_point(position = pd, size = 6)


Feve1<- fig1 +
  xlab("Habitat") + ylab("FEve")  + theme_bw()  + facet_wrap(~River, ncol=5)+
  scale_colour_manual(values=Plot_colours) +
  theme(axis.text.x = element_text(angle = 0, hjust = 0.5, size=20), 
        axis.text.y = element_text(size=20),
        strip.text = element_text(size=20), 
        axis.title.x =element_text(size=25),
        axis.title.y =element_text(size=25),
        plot.tag=element_text(size=30),
        panel.grid.major = element_blank(), panel.grid.minor = element_blank(),
        panel.background = element_blank(), axis.line = element_line(colour = "black"), 
        legend.key=element_blank(),
        legend.position = c("none"), 
        legend.text=element_text(size=20), 
        legend.title=element_text(size=25)) + labs(tag = "e)")

Data structure as follows from dput() function:

structure(list(Habitat = c("Gravel", "Gravel", "Gravel", "Gravel", 
"Gravel", "Gravel", "Gravel", "Gravel", "Gravel", "Gravel", "Gravel", 
"Gravel", "Gravel", "Gravel", "Gravel", "Gravel", "Gravel", "Gravel", 
"Gravel", "Gravel", "Gravel", "Gravel", "Gravel", "Gravel", "Gravel", 
"Gravel", "Gravel", "Gravel", "Gravel", "Gravel", "Gravel", "Gravel", 
"Gravel", "Gravel", "Gravel", "Gravel", "Gravel", "Gravel", "Gravel", 
"Gravel", "Gravel", "Gravel", "Gravel", "Gravel", "Gravel", "Gravel", 
"Gravel", "Gravel", "Gravel", "Gravel", "Gravel", "Gravel", "Gravel", 
"Gravel", "Gravel", "Gravel", "Gravel", "Gravel", "Gravel", "Gravel", 
"Gravel", "Gravel", "Gravel", "Gravel", "Gravel", "Gravel", "Gravel", 
"Gravel", "Gravel", "Gravel", "Gravel", "Gravel", "Gravel", "Gravel", 
"Gravel", "Gravel", "Gravel", "Gravel", "Gravel", "Gravel", "Gravel", 
"Gravel", "Gravel", "Gravel", "Gravel", "Gravel", "Gravel", "Gravel", 
"Gravel", "Gravel", "Gravel", "Sand", "Sand", "Sand", "Sand", 
"Sand", "Sand", "Sand", "Sand", "Sand", "Sand", "Sand", "Sand", 
"Sand", "Sand", "Sand", "Sand", "Sand", "Sand", "Sand", "Sand", 
"Sand", "Sand", "Sand", "Sand", "Sand", "Sand", "Sand", "Sand", 
"Sand", "Sand", "Sand", "Sand", "Sand", "Sand", "Sand", "Sand", 
"Sand", "Sand", "Sand", "Sand", "Sand", "Sand", "Sand", "Sand", 
"Sand", "Sand", "Sand", "Sand", "Sand", "Sand", "Sand", "Sand", 
"Sand", "Sand", "Sand", "Sand", "Sand", "Sand", "Sand", "Sand", 
"Sand", "Sand", "Sand", "Sand", "Sand", "Sand", "Sand", "Sand", 
"Sand", "Sand", "Sand", "Sand", "Sand", "Sand", "Sand", "Sand", 
"Sand", "Sand", "Sand", "Sand", "Sand", "Sand", "Silt", "Silt", 
"Silt", "Silt", "Silt", "Silt", "Silt", "Silt", "Silt", "Silt", 
"Silt", "Silt", "Silt", "Silt", "Silt", "Silt", "Silt", "Silt", 
"Silt", "Silt", "Silt", "Silt", "Silt", "Silt", "Silt", "Silt", 
"Silt", "Silt", "Silt", "Silt", "Silt", "Silt", "Silt", "Silt", 
"Silt", "Silt", "Silt", "Silt", "Silt", "Silt", "Silt", "Silt", 
"Silt", "Silt", "Silt", "Silt", "Silt", "Silt", "Silt", "Silt", 
"Silt", "Silt", "Silt", "Silt", "Silt", "Silt", "Silt", "Silt", 
"Silt", "Silt", "Silt", "Silt", "Silt", "Silt", "Silt", "Silt", 
"Silt", "Silt", "Silt", "Silt", "Silt", "Silt", "Silt", "Silt", 
"Silt", "Silt", "Silt", "Silt", "Silt", "Silt", "Silt", "Silt", 
"Silt", "Silt", "Silt", "Silt", "Silt", "Silt", "Silt"), River = c("Mill", 
"Mill", "Mill", "Mill", "Mill", "Mill", "Mill", "Mill", "Mill", 
"Mill", "Gadder", "Gadder", "Gadder", "Gadder", "Gadder", "Gadder", 
"Gadder", "Gadder", "Gadder", "Gadder", "Gadder", "Gadder", "Gadder", 
"Little Stour", "Little Stour", "Little Stour", "Little Stour", 
"Little Stour", "Little Stour", "Little Stour", "Little Stour", 
"Mill", "Mill", "Mill", "Mill", "Mill", "Mill", "Mill", "Mill", 
"Mill", "Frome", "Frome", "Frome", "Frome", "Frome", "Frome", 
"Frome", "Frome", "Frome", "Frome", "Frome", "Frome", "Frome", 
"Frome", "Frome", "Frome", "Frome", "Frome", "Frome", "Frome", 
"Frome", "Frome", "Frome", "Frome", "Frome", "Frome", "Frome", 
"Frome", "Frome", "Frome", "Frome", "Frome", "Frome", "Frome", 
"Frome", "Frome", "Wool", "Wool", "Wool", "Wool", "Wool", "Wool", 
"Wool", "Wool", "Wool", "Wool", "Wool", "Wool", "Wool", "Wool", 
"Wool", "Mill", "Mill", "Mill", "Mill", "Mill", "Mill", "Mill", 
"Mill", "Mill", "Mill", "Gadder", "Gadder", "Gadder", "Gadder", 
"Gadder", "Gadder", "Gadder", "Gadder", "Gadder", "Gadder", "Gadder", 
"Gadder", "Gadder", "Gadder", "Little Stour", "Little Stour", 
"Little Stour", "Little Stour", "Little Stour", "Little Stour", 
"Little Stour", "Little Stour", "Little Stour", "Little Stour", 
"Little Stour", "Little Stour", "Mill", "Mill", "Mill", "Mill", 
"Mill", "Mill", "Mill", "Mill", "Mill", "Frome", "Frome", "Frome", 
"Frome", "Frome", "Frome", "Frome", "Frome", "Frome", "Frome", 
"Frome", "Frome", "Frome", "Frome", "Frome", "Frome", "Frome", 
"Frome", "Frome", "Frome", "Frome", "Frome", "Frome", "Frome", 
"Frome", "Wool", "Wool", "Wool", "Wool", "Wool", "Wool", "Wool", 
"Wool", "Wool", "Wool", "Wool", "Wool", "Mill", "Mill", "Mill", 
"Mill", "Mill", "Mill", "Mill", "Mill", "Mill", "Mill", "Gadder", 
"Gadder", "Gadder", "Gadder", "Gadder", "Gadder", "Gadder", "Gadder", 
"Gadder", "Gadder", "Gadder", "Gadder", "Little Stour", "Little Stour", 
"Little Stour", "Little Stour", "Little Stour", "Little Stour", 
"Little Stour", "Little Stour", "Little Stour", "Little Stour", 
"Little Stour", "Little Stour", "Mill", "Mill", "Mill", "Mill", 
"Mill", "Mill", "Mill", "Mill", "Mill", "Mill", "Frome", "Frome", 
"Frome", "Frome", "Frome", "Frome", "Frome", "Frome", "Frome", 
"Frome", "Frome", "Frome", "Frome", "Frome", "Frome", "Frome", 
"Frome", "Frome", "Frome", "Frome", "Frome", "Frome", "Frome", 
"Frome", "Frome", "Frome", "Frome", "Frome", "Frome", "Frome", 
"Frome", "Frome", "Frome", "Wool", "Wool", "Wool", "Wool", "Wool", 
"Wool", "Wool", "Wool", "Wool", "Wool", "Wool", "Wool"), Feve = c(0.506977035, 
0.658168517, 0.5552127, 0.674176982, 0.568126029, 0.470484617, 
0.546243187, 0.557337037, 0.549162764, 0.51482439, 0.296783107, 
0.540411614, 0.441655613, 0.748657363, 0.586072179, 0.562687945, 
0.679463256, 0.640924761, 0.76043005, 0.570535503, 0.345381789, 
0.7466591, 0.697030182, 0.397968864, 0.370615261, 0.512819438, 
0.251546229, 0.570256251, 0.346010274, 0.243989438, 0.879881015, 
0.578277252, 0.586240417, 0.653396257, 0.641415819, 0.524595729, 
0.536800538, 0.519825276, 0.521801451, 0.465289634, 0.838068847, 
0.487272624, 0.665124783, 0.629608162, 0.400335866, 0.538598014, 
0.614481336, 0.50953854, 0.564571301, 0.434708346, 0.603286877, 
0.389340894, 0.451569201, 0.664220591, 0.625448998, 0.47830779, 
0.610677015, 0.592997649, 0.389771325, 0.345401462, 0.368971704, 
0.515001741, 0.49651484, 0.49955372, 0.538803174, 0.430966396, 
0.601647539, 0.450264668, 0.510230055, 0.455519866, 0.382308378, 
0.541156034, 0.48855963, 0.454064886, 0.628266636, 0.588126731, 
0.694832118, 0.721497295, 0.652815016, 0.614719973, 0.629744193, 
0.556498854, 0.599436173, 0.537701923, 0.634997581, 0.422792666, 
0.54448257, 0.61526252, 0.644073418, 0.463178528, 0.53049777, 
0.73680085, 0.654108793, 0.508193606, 0.784465676, 0.625011416, 
0.370492072, 0.615810028, 0.758132891, 0.733838212, 0.699321368, 
0.680547958, 0.631187485, 0.580031627, 0.669025786, 0.578582091, 
0.720102863, 0.610043844, 0.705463595, 0.736388029, 0.626156558, 
0.665129554, 0.736158535, 0.635527589, 0.667806898, 0.719755199, 
0.516756193, 0.743297471, 0.385352895, 0.032755073, 0.370695443, 
0.411080389, 0.610129264, 0.44115061, 0.436587861, 0.646474891, 
0.4632019, 0.544676459, 0.70722696, 0.775250617, 0.386924944, 
0.681213071, 0.785576735, 0.653825379, 0.765341039, 0.531730415, 
0.496468683, 0.568045574, 0.559047785, 0.618799013, 0.595831336, 
0.62825441, 0.566092305, 0.424579031, 0.475876404, 0.456873779, 
0.547629079, 0.650585859, 0.573124305, 0.723337968, 0.5208022, 
0.682698101, 0.639284704, 0.633086197, 0.561406514, 0.680181535, 
0.459038805, 0.471462813, 0.731018956, 0.634841981, 0.721187209, 
0.702791349, 0.744408386, 0.595889197, 0.48472181, 0.560199898, 
0.608437475, 0.707858755, 0.675909255, 0.735408435, 0.435542404, 
0.6053562, 0.595449887, 0.520702662, 0.645871555, 0.557698442, 
0.771899899, 0.508251962, 0.694331707, 0.549159191, 0.53994213, 
0.547164043, 0.644919934, 0.699196417, 0.735875306, 0.667984496, 
0.630353871, 0.718764016, 0.398504512, 0.668611595, 0.436300968, 
0.562561037, 0.656273832, 0.71630428, 0.626932262, 0.733307825, 
0.669013893, 0.837176403, 0.298035491, 0.810612337, 0.777539406, 
0.790902907, 0.713633147, 0.626837346, 0.571953853, 0.745992741, 
0.533352203, 0.755656202, 0.548742714, 0.327365258, 0.72424353, 
0.528402042, 0.540123857, 0.688264186, 0.541088378, 0.675038588, 
0.71309915, 0.651328765, 0.56050516, 0.632870384, 0.480536671, 
0.549664771, 0.58966238, 0.648690841, 0.543502869, 0.583063433, 
0.522673603, 0.656145405, 0.389555701, 0.52203683, 0.560684461, 
0.469447718, 0.639486253, 0.594082402, 0.57815447, 0.633922141, 
0.480927001, 0.605528679, 0.665749149, 0.401690615, 0.344411136, 
0.382189728, 0.681118444, 0.519816427, 0.47681727, 0.470170962, 
0.478776858, 0.694232011, 0.696928503, 0.705804165, 0.691504978, 
0.771564279, 0.634355679, 0.540054854, 0.580389632, 0.648298349, 
0.599541806, 0.375901167, 0.471454503, 0.361917446, 0.487022267, 
0.597901339)), class = "data.frame", row.names = c(NA, -262L))
1

There are 1 best solutions below

7
On

If we want to add an extra facet that contains all the data, we can achieve this by row-binding a second copy of the data frame onto the original, where the faceting variable is replaced with the single string "all":

library(tidyverse)

Summer %>%
  bind_rows(Summer %>% mutate(River = 'ALL')) %>%
  mutate(River = factor(River, c(levels(factor(Summer$River)), 'ALL'))) %>%
  ggplot(aes(Habitat, Feve, colour = Habitat)) + 
  geom_point(position = position_jitter(width = 0.1), size = 2, alpha = 0.2) +
  geom_errorbar(stat = 'summary', fun.data = 'mean_se', color = 'black',
                width = 0.2, linewidth = 0.7) +
  geom_point(stat = 'summary', fun = 'mean', color = 'black',
             aes(group = interaction(River, Habitat))) +
  facet_wrap(~ River, ncol = 3) +
  labs(x = "Habitat", y = "FEve", tag = "e") +
  theme_bw(base_size = 16)  + 
  theme(panel.grid.major = element_blank(), 
        panel.grid.minor = element_blank(),
        panel.background = element_blank(), 
        axis.line = element_line(colour = "black"),
        legend.position = c("none"))

enter image description here