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

发布于 2024-12-24 03:58:01 字数 798 浏览 2 评论 0原文

我想使用 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"))

我收到以下错误消息:

“警告消息: 在 xy.coords(x, y, recycle = TRUE) 中:通过强制引入的 NA"

我做错了什么?

I would like to plot results from a MDS analysis with 3 dimensions using plot3d() (rgl). Data and code look like this:

   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"))

I get the following error message:

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

What am I doing wrong?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

困倦 2024-12-31 03:58:01

使用 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))

Use text3d rather than trying to mix text (base graphics) with rgl graphics ...

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))
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文