【问题标题】:R plotly scatter3d: How to make nearest marker appear the biggest?R plotly scatter3d:如何使最近的标记出现最大?
【发布时间】:2021-09-03 18:33:45
【问题描述】:

目前我的代码如下所示:

library(plotly)

count = data.frame(
    row.names = c("Cell1", "Cell2", "Cell3", "Cell4", "Cell5", "Cell6"),
    Gene1 = c(10, 11, 8, 3, 2, 1),
    Gene2 = c(6, 4, 5, 3, 2.8, 1),
    Gene3 = c(12, 9, 10, 2.5, 1.3, 2),
    Gene4 = c(5, 7, 6, 2, 4, 7),
    
    stringsAsFactors = FALSE
)

threeD = plotly::plot_ly(
    data = count,
    x = ~Gene1,
    y = ~Gene2,
    z = ~Gene3,
    type = "scatter3d",
    mode = "markers",
    marker = list(size = 20),
    color = row.names(count)
)
threeD

此代码生成以下输出:

我想让标记随距离缩放。因此,离“我”最近的标记更大(Cell1 和 Cell 2),而远离“我”的标记显得更小(Cell5 和 Cell6)。这将实现更逼真的 3D 感觉。

【问题讨论】:

    标签: r plot plotly bioinformatics scatter3d


    【解决方案1】:

    可以通过为标记分配大小列表来制作一种“气泡”图,以便它们根据各自沿 z 轴的值增长。最简单的方法是重用相同的数据并根据需要应用一些缩放功能(产品、日志等),例如:

    marker = list(size = c(12, 9, 10, 2.5, 1.3, 2)*5)
    

    问题在于,如果您改变观点,标记将不会神奇地更新为预期的 3D 感觉。

    您还可以通过将colorscale 属性添加到标记对象来使用颜色缩放,例如:

    colorscale = c('#FFE1A1', '#683531')
    

    【讨论】:

    • 比你!要去试试这个! :)
    猜你喜欢
    • 2021-11-20
    • 1970-01-01
    • 2021-05-16
    • 2016-11-25
    • 1970-01-01
    • 2020-01-04
    • 2012-04-05
    • 1970-01-01
    • 2019-03-19
    相关资源
    最近更新 更多