Skip to contents

Quickly vizualise MDS and NMDS objects and build customs plots using the layers. See examples.

Usage

plot_NMDS(
  x,
  f = NULL,
  axes = c(1, 2),
  points = TRUE,
  points_transp = 1/4,
  chull = TRUE,
  chullfilled = FALSE,
  labelgroups = FALSE,
  legend = TRUE,
  title = "",
  box = TRUE,
  axesnames = TRUE,
  palette = pal_qual
)

plot_MDS(
  x,
  f = NULL,
  axes = c(1, 2),
  points = TRUE,
  points_transp = 1/4,
  chull = TRUE,
  chullfilled = FALSE,
  labelgroups = FALSE,
  legend = TRUE,
  title = "",
  box = TRUE,
  axesnames = TRUE,
  palette = pal_qual
)

Arguments

x

the result of MDS or NMDS

f

factor specification to feed fac_dispatcher

axes

numeric of length two to select PCs to use (c(1, 2) by default)

points

logical whether to draw this with layer_points

points_transp

numeric to feed layer_points (default:0.25)

chull

logical whether to draw this with layer_chull

chullfilled

logical whether to draw this with layer_chullfilled

labelgroups

logical whether to draw this with layer_labelgroups

legend

logical whether to draw this with layer_legend

title

character if specified, fee layer_title (default to "")

box

logical whether to draw this using layer_box

axesnames

logical whether to draw this using layer_axesnames

palette

color palette to use col_summer by default

Value

a plot

See also

Examples

### First prepare an NMDS object
x <- bot %>% efourier %>% NMDS
#> 'norm=TRUE' is used and this may be troublesome. See ?efourier #Details
#> 'nb.h' set to 10 (99% harmonic power)
#> 'comm' has negative data: 'autotransform', 'noshare' and 'wascores' set to FALSE
#> Warning: results may be meaningless because data have negative entries
#>                  in method “bray”
#> Run 0 stress 0.07227125 
#> Run 1 stress 0.07227125 
#> ... New best solution
#> ... Procrustes: rmse 5.165599e-06  max resid 1.848616e-05 
#> ... Similar to previous best
#> Run 2 stress 0.07227125 
#> ... New best solution
#> ... Procrustes: rmse 1.848561e-06  max resid 7.686046e-06 
#> ... Similar to previous best
#> Run 3 stress 0.1610098 
#> Run 4 stress 0.07227125 
#> ... Procrustes: rmse 6.814352e-06  max resid 2.80386e-05 
#> ... Similar to previous best
#> Run 5 stress 0.07227125 
#> ... Procrustes: rmse 8.042268e-06  max resid 3.293377e-05 
#> ... Similar to previous best
#> Run 6 stress 0.07227125 
#> ... Procrustes: rmse 2.510741e-06  max resid 7.634959e-06 
#> ... Similar to previous best
#> Run 7 stress 0.1660041 
#> Run 8 stress 0.07227125 
#> ... Procrustes: rmse 1.181586e-06  max resid 3.464235e-06 
#> ... Similar to previous best
#> Run 9 stress 0.1642555 
#> Run 10 stress 0.07227125 
#> ... Procrustes: rmse 5.427893e-06  max resid 2.018695e-05 
#> ... Similar to previous best
#> Run 11 stress 0.07227125 
#> ... Procrustes: rmse 1.396985e-06  max resid 6.777242e-06 
#> ... Similar to previous best
#> Run 12 stress 0.07227125 
#> ... Procrustes: rmse 5.297107e-06  max resid 2.060719e-05 
#> ... Similar to previous best
#> Run 13 stress 0.07227125 
#> ... Procrustes: rmse 5.87307e-06  max resid 2.1449e-05 
#> ... Similar to previous best
#> Run 14 stress 0.1660723 
#> Run 15 stress 0.07227125 
#> ... Procrustes: rmse 8.005086e-06  max resid 3.40387e-05 
#> ... Similar to previous best
#> Run 16 stress 0.07227125 
#> ... Procrustes: rmse 4.941503e-06  max resid 1.943066e-05 
#> ... Similar to previous best
#> Run 17 stress 0.1591579 
#> Run 18 stress 0.07227125 
#> ... Procrustes: rmse 1.363299e-06  max resid 5.158787e-06 
#> ... Similar to previous best
#> Run 19 stress 0.07227125 
#> ... Procrustes: rmse 5.783015e-06  max resid 2.420838e-05 
#> ... Similar to previous best
#> Run 20 stress 0.07227125 
#> ... Procrustes: rmse 3.842551e-06  max resid 1.520619e-05 
#> ... Similar to previous best
#> *** Best solution repeated 14 times

plot_NMDS(x)
#> Error in int_abline(a = a, b = b, h = h, v = v, untf = untf, ...): plot.new has not been called yet
plot_NMDS(x, ~type) %>% layer_stars() %>% layer_labelpoints()
#> Error in int_abline(a = a, b = b, h = h, v = v, untf = untf, ...): plot.new has not been called yet

### Same on MDS object
x <- bot %>% efourier %>% MDS
#> 'norm=TRUE' is used and this may be troublesome. See ?efourier #Details
#> 'nb.h' set to 10 (99% harmonic power)

plot_MDS(x)
#> Error in int_abline(a = a, b = b, h = h, v = v, untf = untf, ...): plot.new has not been called yet
plot_MDS(x, ~type) %>% layer_stars() %>% layer_labelpoints()
#> Error in int_abline(a = a, b = b, h = h, v = v, untf = untf, ...): plot.new has not been called yet