As part of my study, I am trying to highlight the proportion of forest and grassland ground beetle communities present in woodland pastures which are a transition zone between the two previous habitats.
I first performed an NMDS. I then extracted the X and Y coordinates of the NMDS for 29 study sites representing ground beetle communities, in order to insert them into a ggplot. In these 29 sites, 4 are considered as forest, 6 as unwooded pasture and 19 as wooded pasture.
I also have a variable that shows the density of trees for each of the 29 study sites.
I try in vain to put in a ggplot both my 29 points with a colour gradient corresponding to my tree density variable and my three ellipses coloured by 3 different colours representing the 3 habitats (forest, unwooded pasture and wooded pasture)
Here is the code that puts the 3 habitats with 3 different coloured ellipses (what I want). But the points represent the 3 habitats and not the woody density variable which could be represented by a colour gradient.
ggplot(dune.nmds.data, aes(x = dune.nmds.data$NMDS1, y = dune.nmds.data$NMDS2, color = Habitats)) + geom_point() + stat_ellipse()+theme_bw()+xlab("NMDS1")+ylab("NMDS2")+ggtitle("NMDS of carabid communities")+ theme(plot.title = element_text(hjust = 0.5))+ scale_color_manual(values=c("F"="#993D00", "WP"="#117733", "NWP"="#FFCC00"))
The second graph and code gives me this time the points with a colour gradient corresponding to the density of trees, but the ellipses do not represent the habitats with distinct colours and there is no label.
ggplot(dune.nmds.data, aes(dune.nmds.data$NMDS1, dune.nmds.data$NMDS2, color=wood_density, group = Habitats)) + geom_point(size=3) + stat_ellipse()
Furthermore, I try to insert my coloured gradient of tree density with my coloured ellipses representing my 3 habitats, but I get this error message: Error: Discrete value supplied to continuous scale.
Do you have an idea ?
I hope that I have been precise enough and I thank you in advance.