I am working on some multivariate data; the ordination required 3 dimensions as the stress was too high. I wanted to see all three at once. In particular, I wanted to see the hull (a polygon enclosing all points) for each site. In our case we have sites with repeated measures, hence site being the grouping variable. Searched on stackoverflow etc, found code to plot more than one hull (https://stackoverflow.com/questions/41145959/picture-convex-hull-in-3d-scatter-plot). Code for the following below.
Earlier this year I attended the National Wetland Trust’s annual wetland symposium, which brings together wetland managers (both paid and volunteer), government, local body university and research wetland scientists along with students and interested lay people. My involvement this year was through my work on two wetlands that are recognised as being internationally significant under the Ramsar convention.
Parts of the interweb seem to equate 3D graphs with killing statistical kittens (*). And they’re verboten in ggplot2 for visualisation philosophy reasons. But sometimes other options (splitting one continuous variable into a factor, facetting, or using colour and or size) aren’t adequate; sometimes someone higher up the food chain than you has requested one; sometimes you have to live dangerously.
(*) interest in poor practice piqued? More bad graphs here.
Provided you know how to predict from your model (and if not, see the “model_prediction” R markdown file or pdf here) it’s not very hard. But I’ve had a couple of requests for sample code, so I reproduce it here too.
Sometimes, you can combine two problems and create a solution. I’m on the student post-graduate committee for the School of Biology at the University of Canterbury, and we were aware that senior postgraduate students were seeking more teaching opportunities. We knew students in the school had a variety of experience both in statistics and in R, which is a statistics programme commonly used in ecology.
Updated: small fix of the “mult” arrow multiplier, thanks to Laura Barrero
A friend requested an RDA version of plotting ordinations in ggplot. I found a Q&A on the ggplot2 mailing list, but they had had some issues. So, I post the code here that I wrote up, using the dune dataset which is in vegan. Clearly we would not be plotting all of this in such a hot mess of a plot, but add and subtract the elements you need/want/like.
This script will print and plot a lot of the results as it goes along, so you can see what you are building.
North Carolina, my first taste of America out of LAX. Warm, of course, coming from mid-winter New Zealand. Shuttle driver, kind, talkative and living the American dream. And the noises! The soundscape was the biggest reminder of the distance from home. The deathbirds I’d previously only heard on Bones when they find dead bodies: everywhere. Discomfiting, a little. Frogs, especially in the evenings, although obnoxiously shy. And aircon, all the time, by necessity.
It took a while, but I can now ordisurf in ggplot2. No extraneous chatter because I go to data camp (more specifically, NCEAS’ Open Science for Synthesis workshop, with RENCI, where I’ll be based) tomorrow! Not packed yet..
Example ordination (from our biol270 field trip data):
NMDS in ggplot2