Skip to content

plot betadisper, change of pch

3 messages · Albin Blaschka, Uwe Ligges, David Winsemius

#
Hello!

After performing an analysis with betadisper, package vegan I would like 
to plot the results - so far, so good. But I would also like to "tune" a 
little bit the plotting characters, as '+' and 'x' are a little to 
similar...

My (boiled down) code:

[See session info at the bottom of the mail, vegan is vegan_2.0-3]

mod <- betadisper(mydata, mygroups, type='median')
syms <- c(rep(1:4, each = 16))
modplot <- plot(mod, axes = c(1,2), main='', pch=syms)

I get the error message (roughly translated from german):
"formal argument 'pch' fits to more given arguments"
[formales Argument "pch" passt zu mehreren gegebenen Argumenten]

What do I have to change?

Thank you in advance!
Albin

 > sessionInfo()
R version 2.15.0 (2012-03-30)
Platform: x86_64-pc-linux-gnu (64-bit)

locale:
  [1] LC_CTYPE=de_AT.UTF-8       LC_NUMERIC=C 
LC_TIME=de_AT.UTF-8        LC_COLLATE=de_AT.UTF-8
  [5] LC_MONETARY=de_AT.UTF-8    LC_MESSAGES=de_AT.UTF-8    LC_PAPER=C 
                LC_NAME=C
  [9] LC_ADDRESS=C               LC_TELEPHONE=C 
LC_MEASUREMENT=de_AT.UTF-8 LC_IDENTIFICATION=C

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base

other attached packages:
[1] rgl_0.92.798      reshape_0.8.4     plyr_1.7.1        MASS_7.3-16 
     vegan_2.0-3       permute_0.7-0     RPostgreSQL_0.3-2
[8] DBI_0.2-5

loaded via a namespace (and not attached):
[1] grid_2.15.0    lattice_0.20-6 tools_2.15.0
#
Runnig the examples from ?betadisper and adding a pch statement gives:

 >      plot(mod, pch=2)
Error in plot.xy(xy.coords(x, y), type = type, ...) :
   formal argument "pch" matched by multiple actual arguments

 > traceback()
5: plot.xy(xy.coords(x, y), type = type, ...)
4: points.default(g$centroids, pch = 16, cex = 1, col = "red", ...)
3: points(g$centroids, pch = 16, cex = 1, col = "red", ...)
2: plot.betadisper(mod, pch = 2)
1: plot(mod, pch = 2)

This shows that the author hardcoded the pch in the code, hence you can 
only change it by changing the code - or send a feature request to the 
vegan maintainer (ideally including a patch, CCing).

Best,
Uwe Ligges
On 09.05.2012 12:20, Albin Blaschka wrote:
#
On May 9, 2012, at 6:20 AM, Albin Blaschka wrote:

            
In such an instance you generally need to get the code of a possibly  
hidden function named "plot.<class-returned-by-betadisp>" where you  
get the class by running:

class(mod)  # then type
plot.<that-result>  # and if that fails
getAnywhere(plot.<that-result>)

Then go in and either add a 'pch' argument or change the hardcoded  
values in the function body.

As it turns out you can see the function without even loading vegan  
just by doing this:

vegan:::plot.betadisper

'pch' appears a couple of times and it is colliding with your values  
in the points() calls. The function should probably be written so that  
it can accept a 'pch' argument.