你可以做到,但这有点麻烦。另外我不知道您是否可以一次将一个列表子集化为多个元素,因此您可能必须单独手动更改每个标签。基本上我检查了绘图,然后查看了temp
对象的结构,并找到了标签存储在对象中的位置。然后,我得到了实际上是文本对象的列表元素的索引,并使用子集将它们编辑为其他内容。唯一的事情是我发现我必须一次做每一个,如果你有很多,这会很痛苦。你可以试试这个,我希望它有帮助:
unlist( sapply(temp,'[[',"label") )
[1] "0" "0" "1" "A" "B"
# Make index of which top-level elements of list are text elements
x <- !sapply( sapply(temp,'[[',"label") , is.null )
ind <- seq.int(length(x))
ind <- ind[x]
# Subset and change each one in place
`[[`(`[[`( temp , ind[1] ), "label") <- "WAS"
`[[`(`[[`( temp , ind[2] ), "label") <- "BY"
`[[`(`[[`( temp , ind[3] ), "label") <- "CHANGED"
`[[`(`[[`( temp , ind[4] ), "label") <- "THIS"
`[[`(`[[`( temp , ind[5] ), "label") <- "ME"
# Plot with new labels
grid.draw(temp)
