Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
289 views
in Technique[技术] by (71.8m points)

r - Is there a way to add centroids and spiders to this PCoA plot code?

New here, and to using R in general. I'm trying to modify a script for generating PCoA plots to include centroids and "spiders" (line segments connecting each sample data point to the centroid). Similar to the attached image.1: https://i.stack.imgur.com/Tjj3T.png

This is the code I've been using:

p.pcoa.wuniRM <- plot_ordination(ps2.prev_RM, ord.pcoa.wuniRM, color = "Location", axes = c(4,5)) +
  geom_point(size = 2, aes(shape = Location)) +
  labs(title = "PCoA of wUniFrac Distances", color = "Location") +
  theme(legend.text = element_text(size=5), aspect.ratio = 1)

Is there an easy way to modify this script to get the centroids and spiders graphed, or do I need to find a different script all together?

question from:https://stackoverflow.com/questions/65855808/is-there-a-way-to-add-centroids-and-spiders-to-this-pcoa-plot-code

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You should try the stat_ellipse() function:

p +
 stat-ellipse()

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...