[R] question about cleaning up data labels on a plot3d plot
    Sarah Goslee 
    sarah.goslee at gmail.com
       
    Wed Aug 24 16:55:14 CEST 2016
    
    
  
Sure, you can do any of that in R.
You might benefit from reading some introductory material so you
understand at least graphical parameters and subsetting, but here's
some sample code with fake data that does what you're asking.
library(rgl)
x <- sort(rnorm(10))
y <- rnorm(10)
z <- rnorm(10) + atan2(x, y)
# version one: text only
plot3d(x, y, z, type="n")
text3d(x, y, z, text=letters[1:10], cex=2)
# version two: colored symbols
data.groups <- sample(1:3, size=10, replace=TRUE)
data.colors <- c("red", "purple", "blue")
plot3d(x, y, z, size=8, col=data.colors[data.groups])
Sarah
On Wed, Aug 24, 2016 at 1:57 AM, LMH <lmh_users-groups at molconn.com> wrote:
> Hello,
>
> I am rather unfamiliar with R but need a 3D plot for something I am working
> on.
>
> I was able to generate a plot with the following,
>
> library(rgl)
> setwd("G:/shared_data/R_projects/3D_plot")
> df <- read.table("R_input_3D_PCA-3_RI9_60.txt", header = TRUE)
> plot3d(df$PCA_Axis1, df$PCA_Axis2, df$PCA_Axis3, col="blue", size=10)
>
> My data is tab delimited and looks like,
>
> num  PCA_Axis1   PCA_Axis2   PCA_Axis3
> 11   -0.672164   -0.83449    -1.06511
> 12   -1.23009    1.57928     -0.066808
> 42   2.80029     0.533236    -0.197187
> 60   2.25999     -0.233224   -0.00267827
> 67   1.82422     -0.840649   0.156681
>
> There are a total of 60 rows.
>
> Adding,
>
> text3d(df, text=df$num)
>
> displays my index value on the plot, but the numbers are very hard to read.
> It looks like the the labels are behind the points. Is there any way to
> clean this up some? I guess I could color the points white so I only see the
> numbers.
>
> I also have 2 or three different sub groups within the data. Is there any
> way to have these different groups appear in different colors? I could
> create multiple data.frames if that would help. I am not sure you can
> display data from multiple frames on the same plot.
>
> Suggestions would be appreciated,
>
> LMH
>
    
    
More information about the R-help
mailing list