1

I would like to replace the basic node image to a custom jpg in networkD3 package in R.

Here is an example:

library(networkD3)

# Load data
data(MisLinks)
data(MisNodes)

# Plot
forceNetwork(Links = MisLinks, Nodes = MisNodes,
            Source = "source", Target = "target",
            Value = "value", NodeID = "name",
            Group = "group", opacity = 0.8)

So I would like to create a node like this: enter image description here

Instead of this:

enter image description here

Is it possible?

4

1 回答 1

5

我想将基本节点图像替换为R 中 networkD3 包中的自定义 jpg。 [...] 对我来说,它也适用于任何其他 交互式 R 网络包

例如,你可以做

library(networkD3)
library(visNetwork)
library(dplyr)
data(MisLinks)
data(MisNodes)
visNetwork(
  MisNodes %>% 
    rename("label"=name) %>% 
    mutate(id = seq_len(nrow(MisNodes))-1),
  MisLinks %>% 
    rename("from"=source, "to"=target)
) %>%
  visNodes(
    shape = "image", 
    image = "http://cdn0.iconfinder.com/data/icons/octicons/1024/mark-github-128.png"
  )

给你

在此处输入图像描述

于 2016-09-04T13:08:07.463 回答