title: Why do my fitted values from ordisurf not match actual variable values?
body: <p>Here is my matrix for the NMDS ordination (PA.mm.5p.rel).</p>
  <pre><code>structure(c(0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 
  0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 
  1, 1, 1, 0, 1, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 
  1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 
  0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 
  0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 
  1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 
  0, 1, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 
  0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 
  1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
  0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 
  1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
  0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 
  0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 0, 
  0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
  0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
  0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 
  0, 0, 0, 0, 0, 0, 1), .Dim = c(45L, 8L), .Dimnames = list(c(&quot;3&quot;, 
  &quot;4&quot;, &quot;5&quot;, &quot;7&quot;, &quot;8&quot;, &quot;10&quot;, &quot;11&quot;, &quot;12&quot;, &quot;13&quot;, &quot;15&quot;, &quot;16&quot;, &quot;18&quot;, 
  &quot;19&quot;, &quot;20&quot;, &quot;21&quot;, &quot;22&quot;, &quot;23&quot;, &quot;24&quot;, &quot;25&quot;, &quot;26&quot;, &quot;27&quot;, &quot;28&quot;, &quot;29&quot;, 
  &quot;30&quot;, &quot;31&quot;, &quot;32&quot;, &quot;33&quot;, &quot;34&quot;, &quot;35&quot;, &quot;36&quot;, &quot;37&quot;, &quot;38&quot;, &quot;39&quot;, &quot;40&quot;, 
  &quot;41&quot;, &quot;42&quot;, &quot;43&quot;, &quot;44&quot;, &quot;45&quot;, &quot;46&quot;, &quot;47&quot;, &quot;48&quot;, &quot;49&quot;, &quot;50&quot;, &quot;51&quot;
  ), c(&quot;Onisimus&quot;, &quot;Amphipods&quot;, &quot;Krill&quot;, &quot;Copepods&quot;, &quot;Fish&quot;, &quot;Gammarus&quot;, 
  &quot;Arctic.cod&quot;, &quot;Sand.Lance&quot;)))
  </code></pre>
  <p>Here is my environmental/individual data (PA_Info).</p>
  <pre><code>structure(list(Date = structure(c(3L, 3L, 5L, 5L, 5L, 5L, 5L, 
  5L, 5L, 5L, 6L, 6L, 6L, 6L, 6L, 7L, 7L, 7L, 7L, 7L, 7L, 8L, 9L, 
  10L, 12L, 14L, 15L, 16L, 16L, 16L, 16L, 17L, 18L, 18L, 19L, 19L, 
  19L, 20L, 20L, 20L, 21L, 21L, 22L, 23L, 25L), .Label = c(&quot;2017-07-19&quot;, 
  &quot;2017-07-25&quot;, &quot;2017-08-07&quot;, &quot;2017-08-08&quot;, &quot;2017-08-09&quot;, &quot;2017-08-12&quot;, 
  &quot;2017-08-14&quot;, &quot;2017-08-15&quot;, &quot;2017-08-22&quot;, &quot;2017-09-01&quot;, &quot;2017-09-04&quot;, 
  &quot;2018-07-20&quot;, &quot;2018-07-23&quot;, &quot;2018-07-26&quot;, &quot;2018-07-29&quot;, &quot;2018-07-30&quot;, 
  &quot;2018-08-01&quot;, &quot;2018-08-02&quot;, &quot;2018-08-04&quot;, &quot;2018-08-06&quot;, &quot;2018-08-08&quot;, 
  &quot;2018-08-14&quot;, &quot;2018-08-19&quot;, &quot;2018-08-20&quot;, &quot;2018-08-28&quot;, &quot;2019-08-08&quot;, 
  &quot;2019-08-10&quot;, &quot;2019-08-11&quot;, &quot;2019-08-12&quot;, &quot;2019-08-13&quot;, &quot;2019-08-14&quot;
  ), class = &quot;factor&quot;), Floy = c(NA, NA, NA, NA, NA, NA, NA, NA, 
  NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 
  NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 2019L, 
  2014L, NA, 2060L, NA, 2575L, NA), FishID = structure(c(16L, 15L, 
  25L, 21L, 23L, 22L, 20L, 19L, 18L, 24L, 28L, 26L, 29L, 27L, 30L, 
  8L, 5L, 7L, 4L, 10L, 3L, 11L, 12L, 13L, 31L, 33L, 34L, 35L, 36L, 
  37L, 38L, 39L, 40L, 41L, 42L, 43L, 44L, 45L, 46L, 47L, 48L, 49L, 
  50L, 51L, 53L), .Label = c(&quot;Char 08&quot;, &quot;Char 09&quot;, &quot;Char 112&quot;, 
  &quot;Char 116&quot;, &quot;Char 121&quot;, &quot;Char 123&quot;, &quot;Char 126&quot;, &quot;Char 129&quot;, &quot;Char 130&quot;, 
  &quot;Char 132&quot;, &quot;Char 138&quot;, &quot;Char 150&quot;, &quot;Char 154&quot;, &quot;Char 156&quot;, &quot;Char 54&quot;, 
  &quot;Char 56&quot;, &quot;Char 58&quot;, &quot;Char 60&quot;, &quot;Char 61&quot;, &quot;Char 62&quot;, &quot;Char 63&quot;, 
  &quot;Char 65&quot;, &quot;Char 66&quot;, &quot;Char 68&quot;, &quot;Char 69&quot;, &quot;Char 86&quot;, &quot;Char 87&quot;, 
  &quot;Char 88&quot;, &quot;Char 89&quot;, &quot;Char 90&quot;, &quot;SSS001&quot;, &quot;SSS002&quot;, &quot;SSS003&quot;, 
  &quot;SSS004&quot;, &quot;SSS005&quot;, &quot;SSS006&quot;, &quot;SSS007&quot;, &quot;SSS008&quot;, &quot;SSS009&quot;, &quot;SSS010&quot;, 
  &quot;SSS011&quot;, &quot;SSS012&quot;, &quot;SSS013&quot;, &quot;SSS014&quot;, &quot;SSS015&quot;, &quot;SSS016&quot;, &quot;SSS017A&quot;, 
  &quot;SSS017B&quot;, &quot;SSS018&quot;, &quot;SSS019&quot;, &quot;SSS020&quot;, &quot;SSS021&quot;, &quot;SSS022&quot;, 
  &quot;SSS23&quot;, &quot;SSS24&quot;, &quot;SSS25&quot;, &quot;SSS26&quot;, &quot;SSS27&quot;, &quot;SSS28&quot;, &quot;SSS29&quot;, 
  &quot;SSS30&quot;, &quot;SSS31&quot;, &quot;SSS32&quot;, &quot;SSS33&quot;, &quot;SSS34&quot;, &quot;SSS35&quot;, &quot;SSS36&quot;, 
  &quot;SSS37&quot;, &quot;SSS38&quot;, &quot;SSS39&quot;, &quot;SSS40&quot;, &quot;SSS41&quot;, &quot;SSS42&quot;, &quot;SSS43&quot;, 
  &quot;SSS44&quot;, &quot;SSS45&quot;, &quot;SSS46&quot;, &quot;SSS47&quot;, &quot;SSS48&quot;, &quot;SSS49&quot;, &quot;SSS50&quot;, 
  &quot;SSS51&quot;, &quot;SSS52&quot;, &quot;SSS53&quot;, &quot;TCH01&quot;, &quot;TCH02&quot;, &quot;TCH03&quot;, &quot;TCH04&quot;, 
  &quot;TCH05&quot;, &quot;TCH06&quot;, &quot;TCH07&quot;), class = &quot;factor&quot;), TL = c(71, 33.2, 
  35.5, 59.5, 53.7, 65.3, 54.5, 57.5, 61.5, 60, 56.5, 53.5, 55, 
  57, 61, 38.5, 65.2, NA, NA, 59, 29.5, 17, 79.5, 81.3, 90, NA, 
  67, 73.2, 86, 85, 63.2, 72.4, 65.4, 66.8, 67, 59, 63.2, 79, 75, 
  90.8, 76, 41.4, 82, 83, 77.6), FL = structure(c(55L, 6L, 7L, 
  25L, 16L, 40L, 19L, 22L, 31L, 27L, 21L, 18L, 20L, 22L, 29L, 8L, 
  43L, NA, NA, 25L, 5L, 3L, 67L, 72L, 63L, NA, 44L, 57L, 62L, 71L, 
  35L, 53L, 45L, 47L, 42L, 24L, 39L, 65L, 60L, 73L, 61L, 9L, 69L, 
  70L, 62L), .Label = c(&quot;13.5&quot;, &quot;15.8&quot;, &quot;16&quot;, &quot;16.5&quot;, &quot;28.3&quot;, &quot;31.5&quot;, 
  &quot;34.5&quot;, &quot;38&quot;, &quot;39.4&quot;, &quot;40.6&quot;, &quot;42&quot;, &quot;44&quot;, &quot;46.8&quot;, &quot;48.6&quot;, &quot;50&quot;, 
  &quot;51.5&quot;, &quot;52&quot;, &quot;53&quot;, &quot;53.2&quot;, &quot;53.5&quot;, &quot;55.4&quot;, &quot;56&quot;, &quot;57&quot;, &quot;57.2&quot;, 
  &quot;57.5&quot;, &quot;58&quot;, &quot;58.3&quot;, &quot;58.4&quot;, &quot;58.8&quot;, &quot;59&quot;, &quot;59.2&quot;, &quot;59.6&quot;, &quot;60&quot;, 
  &quot;61&quot;, &quot;61.1&quot;, &quot;61.2&quot;, &quot;61.4&quot;, &quot;61.8&quot;, &quot;62&quot;, &quot;62.5&quot;, &quot;62.6&quot;, &quot;63&quot;, 
  &quot;63.5&quot;, &quot;64&quot;, &quot;65&quot;, &quot;65.4&quot;, &quot;65.6&quot;, &quot;66&quot;, &quot;66.4&quot;, &quot;66.8&quot;, &quot;67&quot;, 
  &quot;67.6&quot;, &quot;68&quot;, &quot;69&quot;, &quot;69.9&quot;, &quot;70&quot;, &quot;70.1&quot;, &quot;70.4&quot;, &quot;72.6&quot;, &quot;72.8&quot;, 
  &quot;75&quot;, &quot;76&quot;, &quot;76 (pcl)&quot;, &quot;76.4&quot;, &quot;76.8&quot;, &quot;77.4&quot;, &quot;77.5&quot;, &quot;78&quot;, 
  &quot;79.8&quot;, &quot;81.4&quot;, &quot;83&quot;, &quot;83.8&quot;, &quot;89.8&quot;), class = &quot;factor&quot;), Girth = c(NA, 
  NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 
  NA, NA, NA, NA, NA, NA, NA, NA, NA, 29, NA, NA, NA, NA, 32.4, 
  31, 30, NA, NA, 31, 36, 38.6, 43, NA, 20.6, 37, 46, 35.4), Mass = c(3400, 
  8.2, 450, 1800, 1500, 2900, 1300, 1300, 2100, 1900, 1650, 1450, 
  1625, 1600, 1850, 550, 2700, 3600, NA, 1300, 237.2, 41.2, 4850, 
  5100, 6000, NA, 2350, 2700, 4550, 5600, 1750, 2400, 2020, 1800, 
  NA, 1940, 2250, 4000, 3720, 5550, 3150, 620, 4350, 6600, 3900
  ), Sex = structure(c(5L, 3L, 5L, 1L, 1L, 5L, 5L, 5L, 1L, 5L, 
  5L, 5L, 5L, 1L, 5L, 5L, 5L, 5L, 1L, 1L, 1L, 3L, 1L, 5L, NA, NA, 
  NA, 5L, 5L, 5L, 1L, 5L, 5L, 1L, 5L, 1L, 1L, 5L, 5L, 5L, 1L, 1L, 
  1L, 5L, 5L), .Label = c(&quot;F&quot;, &quot;F?&quot;, &quot;I&quot;, &quot;J&quot;, &quot;M&quot;), class = &quot;factor&quot;), 
      Year = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
      1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 
      2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 
      2L, 2L, 2L, 2L, 2L), .Label = c(&quot;2017&quot;, &quot;2018&quot;), class = &quot;factor&quot;), 
      MassCat = c(&quot;Medium&quot;, &quot;Small&quot;, &quot;Small&quot;, &quot;Medium&quot;, &quot;Small&quot;, 
      &quot;Medium&quot;, &quot;Small&quot;, &quot;Small&quot;, &quot;Medium&quot;, &quot;Medium&quot;, &quot;Medium&quot;, 
      &quot;Small&quot;, &quot;Medium&quot;, &quot;Medium&quot;, &quot;Medium&quot;, &quot;Small&quot;, &quot;Medium&quot;, 
      &quot;Medium&quot;, NA, &quot;Small&quot;, &quot;Small&quot;, &quot;Small&quot;, &quot;Large&quot;, &quot;Large&quot;, 
      &quot;Large&quot;, NA, &quot;Medium&quot;, &quot;Medium&quot;, &quot;Large&quot;, &quot;Large&quot;, &quot;Medium&quot;, 
      &quot;Medium&quot;, &quot;Medium&quot;, &quot;Medium&quot;, NA, &quot;Medium&quot;, &quot;Medium&quot;, &quot;Large&quot;, 
      &quot;Large&quot;, &quot;Large&quot;, &quot;Medium&quot;, &quot;Small&quot;, &quot;Large&quot;, &quot;Large&quot;, &quot;Large&quot;
      ), Datect = structure(c(1502078400, 1502078400, 1502251200, 
      1502251200, 1502251200, 1502251200, 1502251200, 1502251200, 
      1502251200, 1502251200, 1502510400, 1502510400, 1502510400, 
      1502510400, 1502510400, 1502683200, 1502683200, 1502683200, 
      1502683200, 1502683200, 1502683200, 1502769600, 1503374400, 
      1504238400, 1532059200, 1532577600, 1532836800, 1532923200, 
      1532923200, 1532923200, 1532923200, 1533096000, 1533182400, 
      1533182400, 1533355200, 1533355200, 1533355200, 1533528000, 
      1533528000, 1533528000, 1533700800, 1533700800, 1534219200, 
      1534651200, 1535428800), class = c(&quot;POSIXct&quot;, &quot;POSIXt&quot;), tzone = &quot;&quot;), 
      week = structure(c(4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 
      4L, 4L, 4L, 4L, 4L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 6L, 7L, 1L, 
      2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 
      4L, 4L, 5L, 5L, 7L), .Label = c(&quot;29&quot;, &quot;30&quot;, &quot;31&quot;, &quot;32&quot;, &quot;33&quot;, 
      &quot;34&quot;, &quot;35&quot;), class = &quot;factor&quot;), yday = c(219, 219, 221, 221, 
      221, 221, 221, 221, 221, 221, 224, 224, 224, 224, 224, 226, 
      226, 226, 226, 226, 226, 227, 234, 244, 201, 207, 210, 211, 
      211, 211, 211, 213, 214, 214, 216, 216, 216, 218, 218, 218, 
      220, 220, 226, 231, 240)), row.names = c(10L, 11L, 13L, 14L, 
  15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L, 25L, 26L, 27L, 
  28L, 29L, 30L, 33L, 34L, 35L, 36L, 38L, 40L, 41L, 42L, 43L, 44L, 
  45L, 46L, 47L, 48L, 49L, 50L, 51L, 52L, 53L, 54L, 55L, 56L, 57L, 
  58L, 60L), class = &quot;data.frame&quot;)
  </code></pre>
  <p>Creating the NMDS and a dataframe of the points.</p>
  <pre><code>PA.mm.5p.rel.nmds2&lt;- metaMDS(PA.mm.5p.rel, distance=&quot;bray&quot;, k = 2, autotransform=FALSE)
  
  allNMDS_DF&lt;-as.data.frame(PA.mm.5p.rel.nmds2$points)
  </code></pre>
  <p>Running an ordisurf and using a function to extract x, y, and z coordinates from the sp.sf object.</p>
  <pre><code>sp.sf &lt;- ordisurf(PA.mm.5p.rel.nmds2 ~ PA_Info$TL)
  
  extract.xyz &lt;- function(obj) {
    xy &lt;- expand.grid(x = obj$grid$x, y = obj$grid$y)
    xyz &lt;- cbind(xy, c(obj$grid$z))
    names(xyz) &lt;- c(&quot;x&quot;, &quot;y&quot;, &quot;z&quot;)
    return(xyz)
  }
  </code></pre>
  <p>This is where I extract the coordinates, however the z values in contour.vals do not match the range of values observed in <code>PA_Info$TL</code>. You can also see this within the legend when you plot and compare the scales in &quot;level&quot; to &quot;total length&quot;. Because there are differences I'm worried that I cannot trust this output from the ordisurf or the related p-value (<code>summary(sp.sf)</code>). Does anyone know what could be going wrong?</p>
  <pre><code>contour.vals &lt;- extract.xyz(obj = sp.sf, plot = F)
  head(contour.vals)
  contour.vals &lt;- na.omit(contour.vals)
  
  allNMDS_DFTL &lt;- allNMDS_DF[which(!is.na(PA_Info$TL)),]
  
  p &lt;- ggplot(data = contour.vals, aes(x, y, z = z)) + stat_contour(aes(colour = ..level..)) + 
    coord_cartesian(xlim = c(-2, 2), ylim = c(-1, 1.5)) + theme_bw()+
    geom_point(data = allNMDS_DFTL, aes(MDS1, MDS2, z = 0, shape = PA_Info$Year[which(!is.na(PA_Info$TL))], fill = PA_Info$TL[which(!is.na(PA_Info$TL))]), size=8,shape=21)+
    labs(fill = 'Total Length (cm)') + xlab(&quot;Axis 1 (38.2%)&quot;)+ylab(&quot;Axis 2 (27.9%)&quot;)
  </code></pre>