If you have a look at the code for plotTangentSpace
(just type it in the R console), you first find the 'argument list':
function (A, axis1 = 1, axis2 = 2, warpgrids = TRUE, label = FALSE)
As you see you can turn labels 'on' or 'off' (label = TRUE
or FALSE
), but there is no argument for setting the actual value of the labels. Further down you find the code for the default, hard-coded labels (seq(1, n)
) in two places:
if (label == T) {
text(pcdata[, axis1], pcdata[, axis2], seq(1, n),
adj = c(-0.7, -0.7))
...where pcdata
, axis1
, and n
are defined in the beginning of the function.
Thus, if you want to set the value of the labels, it seems that you need to rewrite the function slightly. One possibility is to add a labels
argument to the arglist
:
function (A, axis1 = 1, axis2 = 2, warpgrids = TRUE, label = FALSE, labels = NULL)
...and change the arguments in both text
calls:
text(pcdata[, axis1], pcdata[, axis2], labels,
adj = c(-0.7, -0.7))
You also need to access the tps
function in the geomorph
namespace. This can be achived by adding geomorph:::
before both instances of tps
:
geomorph:::tps(ref, shape.min, 20)
geomorph:::tps(ref, shape.max, 20)
Then assign the updated function to a new function name:
plotTangentSpace2 <- function (A, axis1 = 1, axis2 = 2, warpgrids = TRUE, label = FALSE, labels = NULL){
lots-of-stuff
text(pcdata[, axis1], pcdata[, axis2], labels,
adj = c(-0.7, -0.7)) # in both places
more-stuff
geomorph:::tps(ref, shape.min, 20)
geomorph:::tps(ref, shape.max, 20)
}
Plot with the updated function, using 'Myname' as labels:
plotTangentSpace2(Y.gpa$coords, label = TRUE, labels = Myname)