我正在寻找使用 Rplotly库来创建 x、y、z 坐标数据的 3D 曲面图,类似于下面的链接所示:
https://plot.ly/r/3d-surface-plots/ https://plot.ly/r/3d-surface-plots/
看来plot_ly函数要求z坐标位于尺寸为x * y的矩阵中,如所示数据集::火山,在链接的示例中使用。我希望获得有关如何构建此矩阵的一些指导。这是我的示例 x,y 坐标数据:
## x coordinates
xSeq = seq(0, 1, .01)
## y coordinates
ySeq = seq(0, 1, .01)
## list with x, y coordinates
exmplList = list(x = xSeq, y = ySeq)
z 坐标将通过 x,y 对的公式计算(此处使用的示例公式是 x + y)。我玩过类似的东西:
exmplList = within(exmplList, z <- matrix(x + y, nrow = length(xSeq), ncol = length(ySeq)))
但这并没有实现我想要实现的配对组合。