[R] Add point label to lattice cloud plot (3D scatter)

Luigi Marongiu m@rong|u@|u|g| @end|ng |rom gm@||@com
Thu Feb 28 11:32:04 CET 2019


Dear all,
is there a way to add the labels of the points to a 3D scatter plot
obtained with lattice's cloud?

I can now plot the data, but when trying to add the label I get the error:
`Error in multiple && !outer : invalid 'x' type in 'x && y'`

The script I wrote runs like this:

>>>
df = data.frame(Name = c("A", "B", "C", "D", "E"),
              x_axis = c(-0.591, 0.384, -0.384, -0.032, 0.754),
              y_axis = c(-1.302, 1.652, -1.652, 0.326, 0.652),
              z_axis = c(1.33, 1.33, 2.213, 0.032, -0.754),
              stringsAsFactors = FALSE)

cloud(z_axis ~ x_axis * y_axis, data = df,
      xlab = "X", ylab = "Y", zlab = "Z",
      pch = 16, col = "red", type = "b", cex = 1.5,
      ltext(x=df$x_axis, y=df$y_axis, z=df$z_axis,
            labels=df$Names, pos=1, offset=1, cex=0.8)
)

<<<
Thank you



More information about the R-help mailing list