【问题标题】:making plotly dendrogram in javascript在javascript中制作情节树状图
【发布时间】:2016-08-05 20:25:16
【问题描述】:

想用 plotly.js 制作https://plot.ly/python/dendrogram/。是吗 可能的?有没有人在 javascript 中实现树状图?

【问题讨论】:

  • 您想同时使用 figurefactory 函数和绘图本身吗?还是您提供数据只是想绘制它?
  • 数据将由外部聚类例程提供,也由来自 plotly.js 的 plotly 热图消耗。

标签: javascript r plotly dendrogram dendextend


【解决方案1】:

不完全回答你的问题,但如果它有帮助 - 你可以使用 R 结合 dendextend 和 plotly 包来做到这一点。这是一个简单的例子:

install.packages(c("ggplot2", "dendextend", "plotly"))

library(dendextend)
# library(ggdendro)
# Create a complex dend:
dend <- iris[1:30,-5] %>% dist %>% hclust %>% as.dendrogram %>% 
  set("branches_k_color", k=3) %>% set("branches_lwd", c(1.5,1,1.5)) %>% 
  set("branches_lty", c(1,1,3,1,1,2)) %>%  
  set("labels_colors") %>% set("labels_cex", c(.9,1.2)) 
# plot the dend in usual "base" plotting engine:   
# plot(dend)
# Now let's do it in ggplot2 :)
ggd1 <- as.ggdend(dend)
library(ggplot2)
p <- ggplot(ggd1, offset_labels = -.1) # reproducing the above plot in ggplot2 :)

library(plotly)
ggplotly(p) %>% layout(showlegend = FALSE)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-07-30
    • 1970-01-01
    • 1970-01-01
    • 2010-12-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多