How can I move graphs so they are paired together?

I've made a graph of mean cover of different species in 3 different areas with the inclusion of one species (y) and exclusion of the same species (n) on different graphhs. however I'm struggling to place the two graphs of y and n together in Rstudio for comparison

please can you help?

composistino3 %>%
  group_by(site, bartsia, species) %>%
  summarise(meancover = mean(cover),
            secover = sd(cover)/sqrt(n())) %>%
  ungroup() %>%
ggplot(aes(x = reorder (species, - meancover), y = meancover, colour = species, fill = species, group = species)) +
  geom_bar(stat="identity", position = "stack") +
  labs(x = "Species", 
       y = "Mean Cover") + 
  theme(axis.text.x = element_blank(),
        axis.ticks.x = element_blank()) +
  #geom_errorbar(aes(ymin = meancover - secover, ymax = meancover + secover)) + 
  facet_wrap(~bartsia+site, ncol=2)

Does facet_grid(site ~ bartsia) give the result you're looking for?

Also, the graph will be much easier to read with Species x-axis labels, rather than a color legend.

1 Like

Thanks for that, that's really helpful.

Another thought is how can I change the Legend so that the species are in the same order as the X-axis?

I also need to make a 3rd graph for each area (I.e.heathland etc) for the average of each species, Any ideas?

thanks in advance :slight_smile:

It will be easier to help you if you provide sample data that we can use to test out modifications to your code.

Hi, here is how the data looks:

Showing the site (ie. healthland, Transition and Woodland), Presence of Bartsia (Y or N), the species composition and the % cover of said species.

Is it possible I will be able to add the third graph and also edit the legend?

site		bartsia	            species	cover
Heathland		Y	Empetrum nigrum	80
Heathland		Y	Vaccinium vitis-idaea	0
Heathland		Y	Vaccinium uliginosum	15
Heathland		Y	Adromeda polifolia	20
Heathland		Y	Sphagnum	0
Heathland		Y	Salix herbacea	0
Heathland		Y	Lichen sprigy	5
Heathland		Y	Lichen flat	20
Heathland		Y	Penguicula	0
Heathland		Y	Betula nana	20
Heathland		N	Empetrum nigrum	50
Heathland		N	Vaccinium vitis-idaea	0
Heathland		N	Vaccinium uliginosum	30
Heathland		N	Adromeda polifolia	35
Heathland		N	Sphagnum	20
Heathland		N	Salix herbacea	0
Heathland		N	Lichen sprigy	20
Heathland		N	Lichen flat	0
Heathland		N	Penguicula	0
Heathland		N	Betula nana	0

We need actual sample data on a copy/paste friendly format, not a screenshot of it.

To help us help you, please prepare a reproducible example (reprex) illustrating your issue. Please have a look at this guide, to see how to create one:

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