I have categorical data on 3 axes (X1
, X2
, X3
) in df
mapping whether something is Y = "Red"
or Y = "Green"
.
R 3d plot with categorical colors
> df
# A tibble: 6 x 7
Obs. X1 X2 X3 Y dist Y1
<chr> <dbl> <dbl> <dbl> <chr> <dbl> <dbl>
1 1 0 3 0 R 3 0
2 2 2 0 0 R 2 0
3 3 0 1 3 R 3.16 0
4 4 0 1 2 G 2.24 1
5 5 -1 0 1 G 1.41 1
6 6 1 1 1 R 1.73 0
I followed the procedure here, but I am getting a white spot (presumably when Y1 = 0). I would like to change the colours to red and green.
library(scatterplot3d)
s3d = with(df, scatterplot3d(X1, X2, X3, colour = as.numeric(Y1), pch = 19))