gpt4 book ai didi

r - 将标签名称绘制到由plot3d(rgl)生成的3D图上

转载 作者:行者123 更新时间:2023-12-04 03:59:53 25 4
gpt4 key购买 nike

我想使用plot3d()( rgl )绘制3维MDS分析的结果。数据和代码如下所示:

   threedim$points
[,1] [,2] [,3] [,4]
Dutch -6.45931417 -2.1589222 -5.829244 -0.4891066
German -7.27770201 0.2666916 -2.198595 6.8658602
Albanian 4.11799731 0.6810336 11.356935 -2.2623921
Armenian 13.58431670 21.6527626 -2.245146 6.3506665
French -0.24170759 -0.8579159 14.197611 -0.1871443

threedim$points[,1] -> x
threedim$points[,2] -> y
threedim$points[,3] -> z
library(rgl)
plot3d(x,y,z)
text(c("Dutch","German","Albanian","Armenian","French"))

我收到以下错误消息:

"Warning message: In xy.coords(x, y, recycle = TRUE) : NAs introduced by coercion"



我究竟做错了什么?

最佳答案

使用text3d而不是尝试将text(基础图形)与rgl图形混合使用...

dat <- read.table(textConnection(
"nation x y z w
Dutch -6.45931417 -2.1589222 -5.829244 -0.4891066
German -7.27770201 0.2666916 -2.198595 6.8658602
Albanian 4.11799731 0.6810336 11.356935 -2.2623921
Armenian 13.58431670 21.6527626 -2.245146 6.3506665
French -0.24170759 -0.8579159 14.197611 -0.1871443"),
header=TRUE,as.is=TRUE)

library(rgl)
with(dat,plot3d(x,y,z))
with(dat,text3d(x,y,z,nation))

关于r - 将标签名称绘制到由plot3d(rgl)生成的3D图上,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8733597/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com