使用离散 3D 点在 R 中绘制 3D 体积图

时间:2021-02-10 17:22:04

标签: r ggplot2 3d plotly

我正在尝试在 R 中创建一个体积图,以显示 3D 空间中点的平滑密度。我目前正在使用 plotly 用 scatter3D 绘图。

  df = data.frame(a = sample(seq(.5,.8,.001),100), 
              b = sample(seq(0,.5,.001),100), 
              c = sample(seq(0,.3,.001),100), 
              value = sample(seq(0,1,.01),100))


plot_ly(df, x = ~a, y = ~b, z = ~c, type = 'scatter3d')

enter image description here

将类型设置为“mesh3d”可以将这些点连接为 3d 空间中的表面。

  plot_ly(df, x = ~a, y = ~b, z = ~c, type = 'mesh3d')

enter image description here

但是,每次尝试将类型设置为“音量”都会给我一个空白图。

  plot_ly(df, x = ~a, y = ~b, z = ~c, value = ~value, type = 'volume', 
          isomin = 0, isomax = 1, opacity = 1)

enter image description here

文档在这里:https://plotly.com/r/reference/volume/ 并指定:

<块引用>

使用由包含 valuexyz 的四个一维数组给出的坐标在 iso-min 和 iso-max 值之间绘制体积轨迹均匀或非均匀 3-D 网格的每个顶点。还可以使用此轨迹绘制水平或垂直切片、上限以及 iso-min 和 iso-max 值之间的空间框架。

python 版本的 plotly 提供了一个示例:https://plotly.com/python/3d-volume-plots/ 但我不知道我在哪里错过了到 R 的转换。我已经包含了体积图的额外值维度,但它没有好像什么都能做。

0 个答案:

没有答案
相关问题