I am trying to plot two sets of points in the same 3D scatterplot using interactive "rgl" package for R
this is the data:
> head(tsne_train)
X1 X2 X3
2 18.940912 -46.761145 -56.1818708
4 17.768953 68.678871 0.8070582
6 -2.440751 -53.021051 55.0437596
7 44.740812 -2.347877 -54.1501468
8 -87.924687 15.354890 -30.1806330
12 21.991465 38.406572 -33.0551010`
> head(tsne_test)
X1 X2 X3
1 1.585156 71.568255 7.438958
3 62.204021 -3.817038 -37.609328
5 5.422276 -21.855152 66.865478
9 21.223133 -29.763255 -107.832779
10 9.037427 -62.816717 65.560664
11 24.775047 -51.820532 57.106795
this is what I tried so far:
scatter3d( x=tsne_train[,1],y=tsne_train[,2],z=tsne_train[,3],
groups = train$Result,
surface=F, grid = T, ellipsoid = FALSE,sphere.size = 1.5,
surface.col = c("red", "orange", "green"),fogtype="none",
axis.col=c("black","black","black"))
and
scatter3d(x=tsne_test[,1],y=tsne_test[,2],z=tsne_test[,3], groups = test$Result,
surface=F, grid = T, ellipsoid = FALSE,sphere.size = 1.5,
col = c("purple", "blue", "cyan"), fogtype="none",
axis.col=c("black","black","black"))
I want all the points in one scatterplot but preserving the color grouping (6 colors in total). Kind of like overlaying plot 2 over plot 1
Using spheres3d to add more points to a plot leads to this mess:
spheres3d(x=tsne_test[,1],y=tsne_test[,2],z=tsne_test[,3],
surface=F, grid = T,
col = c("purple", "blue", "cyan"), sphere.size = 3,
axis.col=c("black","black","black"))
this does not preserve the green/red/orange points from plot #1, the axes aren't visible and the position of the points looks off since plot #2 looks nothing like it. Maybe I am just using spheres3d wrong?





train) and state alllibrarycalls (e.g.car)to enable us to reproduce your code. - jay.sfscatter3dis not anrglfunction. There's a function by that name in thecarpackage. It rescales points before it plots them, so you'll need to figure out how to do the same rescaling to add your points. - user2554330(x - minx)/(maxx - minx)(and similarly foryandz). You should be able to do the same if you use the min and max from the first plot to transform the values in thespheres3dcall. - user2554330