我想用plotly.js制作https://plot.ly/python/dendrogram/。有可能吗?有人用javascript实现过树状图吗?
发布于 2016-08-07 01:44:21
不能完全回答你的问题,但以防万一-你可以结合使用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)

https://stackoverflow.com/questions/38797286
复制相似问题