title: Customizing a vegan pca plot with ggplot2
body: <p>I'm trying to make a custom plot of some vegan rda results in ggplot2. I'm essentially modifying directions as seen in <a href="https://stackoverflow.com/questions/32194193/plotting-rda-vegan-in-ggplot">Plotting RDA (vegan) in ggplot</a>, so that I am using shape and color labels to convey some information about the sample points.</p>
  
  <p>I set up a pca analysis with vegan as follows</p>
  
  <pre><code>library(vegan)
  library(dplyr)
  library(tibble)
  library(ggplot2)
  cbPalette &lt;- c("#000000", "#E69F00", "#56B4E9", "#009E73",  "#0072B2", "#D55E00", "#CC79A7", "#F0E442")
  data(dune)
  data(dune.env)
  dune.pca &lt;- rda(dune)
  uscores &lt;- data.frame(dune.pca$CA$u)
  uscores1 &lt;- inner_join(rownames_to_column(dune.env), rownames_to_column(data.frame(uscores)), type = "right", by = "rowname")
  vscores &lt;- data.frame(dune.pca$CA$v)
  </code></pre>
  
  <p>I can make a simple biplot</p>
  
  <pre><code> biplot(dune.pca)
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/OKj3Y.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/OKj3Y.png" alt="test biplot"></a></p>
  
  <p>Now, lets say I want to know more about the management conditions to which these different samples were subject. I'll color and shape code them and plot with ggplot.</p>
  
  <pre><code>p1 &lt;- ggplot(uscores1, aes(x = PC1, y = PC2, col = Management,
                           shape = Management)) + 
  geom_point() +
  scale_color_manual(values=cbPalette) +
  scale_fill_manual(values=cbPalette) +
  scale_shape_manual(values = c(21:25)) +
  theme_bw() +
  theme(strip.text.y = element_text(angle = 0))
  p1
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/Rle2m.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Rle2m.png" alt="test points"></a></p>
  
  <p>Next, I'd really like to add some biplot arrows that show us the axes corresponding to species abundance. I can use ggplot to plot just those arrows as follows:</p>
  
  <pre><code>p2 &lt;- ggplot() +  geom_text(data = vscores, aes(x = PC1, y = PC2, label = rownames(vscores)), col = 'red') +
  geom_segment(data = vscores, aes(x = 0, y = 0, xend = PC1, yend = PC2), arrow=arrow(length=unit(0.2,"cm")),
              alpha = 0.75, color = 'darkred')
  p2
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/rik19.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/rik19.png" alt="test arrows"></a></p>
  
  <p>What I'd really like to do though, is get those arrows and points on the same plot. Currently this is the code that I am trying to use:</p>
  
  <pre><code>p3 &lt;- p1 + geom_text(data = vscores, aes(x = PC1, y = PC2, label = rownames(vscores)), col = 'red') +
  geom_segment(data = vscores, aes(x = 0, y = 0, xend = PC1, yend = PC2), arrow=arrow(length=unit(0.2,"cm")),
              alpha = 0.75, color = 'darkred')
  p3
  </code></pre>
  
  <p>To my annoyance, this yields only a blank plot (empty window, no error messages). Clearly I am missing something or scaling something incorrectly. Any suggestions about how I can best superimpose the last two plots?</p>