Brooke
Brooke

Reputation: 49

Having problems adding 3d points to existing 3d scatterplot

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?

Thanks in advance

Brooke

Data:

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

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)

Upvotes: 2

Views: 2974

Answers (1)

darwin
darwin

Reputation: 453

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

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)

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)

Upvotes: 3

Related Questions