想用 plotly.js制作https://plot.ly/python/dendrogram/ 。可能吗?有没有人在javascript中实现树状图?
问问题
863 次
1 回答
2
不完全回答您的问题,但如果它有帮助 - 您可以使用 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)
于 2016-08-06T17:44:21.340 回答