代码之家  ›  专栏  ›  技术社区  ›  Marouen

在scatter3d中显示点标签

  •  2
  • Marouen  · 技术社区  · 6 年前

    scatter3d 功能。

    library("car")
    library("rgl")
    scatter3d(geometry[,1],geometry[,2],geometry[,3] , surface=FALSE, labels = rownames(geometry), id.n=nrow(geometry))
    

    这个 tutorial 说添加参数 labels=rownames(geometry), id.n=nrow(geometry) 应该在每个点上显示标签,但这不起作用。

    编辑:

    我上传了坐标文件 here ,你可以这样读

    geometry = read.csv("geometry.txt",sep = " ")
    colnames(geometry) = c("x","y","z")
    

    编辑:

    实际上,即使是教程中的示例也不会标记点,也不会生成显示的绘图。包裹可能有问题。

    scatter3d(x = sep.l, y = pet.l, z = sep.w, 
              surface=FALSE, labels = rownames(iris), id.n=nrow(iris))
    
    1 回复  |  直到 6 年前
        1
  •  2
  •   Naveen    6 年前

    我可以给你一个快速修复,如果你想使用任何其他功能以外的散射三维。这可以通过使用plot3d和text3d函数来实现。我已经提供了如何实现它的基本代码块。你可以根据自己的需要定制。

    plot3d(geometry[,1],geometry[,2],geometry[,3])
    text3d(geometry[,1],geometry[,2],geometry[,3],rownames(geometry))
    points3d(geometry[,1],geometry[,2],geometry[,3], size = 5)
    
        2
  •  0
  •   thistleknot    4 年前

    test2 <- cbind(dataSet[,paste(d)],set.final$Groups,test)
    X <- test2[,1]
    Y <- test2[,2]
    Z <- test2[,3]
    
    # 3D plot with the regression plane
    
    scatter3d(x = X, y = Y, z = Z, groups = test2$`set.final$Groups`,
              grid = FALSE, fit = "linear",ellipsoid = FALSE, surface=FALSE,
              surface.col = c("green", "blue", "red"),
              #showLabels(x = x, y = y, z = z, labels=test2$test, method="identify",n = nrow(test2), cex=1, col=carPalette()[1], location=c("lr"))
              #labels = test2$test,
              id=list(method = "mahal", n = length(test2$test), labels = test2$test)
              #id.n=nrow(test2$test)
    )
              
              
      #identify3d(x = X, y = Y, z = Z, labels = test2$test, n = length(test2$test),  plot = TRUE, adj = c(-0.1, 0.5), tolerance = 20, buttons = c("right"))
      
      
      rglwidget()