[英]3D density plot (from 3D scatter plot)
我正在尋找生成 3D 密度 plot,不透明度描繪區域內的密度(例如,高密度區域顯示深紅色和低密度透明淺紅色)。 類似於此頁面上的 2D 圖表; https://www.r-graph-gallery.com/2d-density-chart.html
作為另一層困難,我希望描繪密度的顏色根據 label(在本例中為細胞類型)而變化。 但我實際上很難找到合適的方法來生成 3D 密度 plot。 有什么建議么?
我用 Wolfram 語言越過了這個; https://reference.wolfram.com/language/ref/DensityPlot3D.html但我希望使用 R 作為我的手段。
作為使用的示例,請參見下面使用 plotly 制作的
set.seed(123)
gene_x <- rnorm(500, mean=280, sd=100)
gene_y <- rnorm(500, mean = 450, sd=150)
gene_z <- rnorm(500, mean = 340, sd=80)
celltype1 <- data.frame(gene_x,gene_y,gene_z)
celltype1['celltype'] = "neuron"
gene_x <- rnorm(400, mean= 60, sd=150)
gene_y <- rnorm(400, mean = 40, sd=100)
gene_z <- rnorm(400, mean = 110, sd=50)
celltype2 <- data.frame(gene_x,gene_y,gene_z)
celltype2['celltype'] = "astrocyte"
df <- rbind(celltype1,celltype2)
library("plotly")
plot_ly(x=df$gene_x, y=df$gene_y, z=df$gene_z, type="scatter3d", mode="markers", color = df$celltype, marker = list(size = 4))
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.