将 3d 点添加到现有 3d 散点图时遇到问题 [英] Having problems adding 3d points to existing 3d scatterplot

查看:29
本文介绍了将 3d 点添加到现有 3d 散点图时遇到问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在尝试为我的项目生成 3d 散点图.正如您在下面看到的,我将物种列子集划分为三个不同的子集以分离出三个物种.我正在设法使用三个数据集之一生成散点图,但是我在从其他两个数据集向现有散点图添加点时遇到问题.是我做错了什么还是遗漏了什么?

I'm currently attempting to generate a 3d scatterplot for my project. As you can see below I've subset the species column into three different subsets to seperate out the three species. I'm managing to generate the scatterplot fine with one of the three data sets but I'm having problems adding points to the existing scatterplot from the other two data sets. Is there something I'm doing wrong or something I'm missing?

提前致谢

布鲁克

数据:

Species      Mid_X    Mid_Y     Mid_Z 
Cod         -226.483    290.807 -1770.277
Cod          624.474    280.285 -1762.328
Cod          665.449    243.107 -1961.12
Cod         -561.352    297.365 -1843.93
Cod         -513.858    361.52  -1957.867
Haddock       61.303    -172.153    -1482.718
Haddock       57.876    -244.111    -1278.529
Haddock      209.822    -195.276    -1287.596
Haddock      486.066    -186.823    -1628.798
Whiting      260.514    -232.993    -1301.227
Whiting     71.793  35.854  -1173.601
Whiting     4.147   -44.185 -1282.338

代码:WCC <- read.csv("WaterColumnCurrent.csv")鳕鱼 <- 子集(WCC,物种 ==鳕鱼")黑线鳕<-子集(WCC,物种==黑线鳕")Whiting <- subset(WCC, Species == "Whiting")

Code: WCC <- read.csv("WaterColumnCurrent.csv") Cod <- subset(WCC, Species == "Cod") Haddock <- subset(WCC, Species == "Haddock") Whiting <- subset(WCC, Species == "Whiting")

scatterplot3d(Cod$Mid_X, Cod$Mid_Z, Cod$Mid_Y, pch=20)
points3d(Haddock$Mid_X, Haddock$Mid_Z, Haddock$Mid_Y, pch=2)

推荐答案

这里有一些差异的细目分类(在我含糊的评论之后),还有一些代码.

Here is a little breakdown of the difference (after my vague comment), with some code.

使用 scatterplot3d 库:

Using scatterplot3d library:

spl <- scatterplot3d(WCC$Mid_X, WCC$Mid_Z, WCC$Mid_Y, pch=20, type="n")
spl$points3d(Haddock$Mid_X, Haddock$Mid_Z, Haddock$Mid_Y, pch=2)

或者使用 rgl 库:

Or using the rgl library:

plot3d(WCC$Mid_X, WCC$Mid_Z, WCC$Mid_Y, pch=20, type="n")
points3d(Haddock$Mid_X, Haddock$Mid_Z, Haddock$Mid_Y, pch=2)

这篇关于将 3d 点添加到现有 3d 散点图时遇到问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆