如何在igraph包的visIgraph中制作的图形中添加带有过滤器颜色的标题?

时间:2019-04-02 20:14:58

标签: r igraph

我有一个用“ igraph”包的VisIgraph制作的图形。此代码按颜色过滤图形的数据。我的问题是给颜色加上标题。

'''

V(g1)$color <- ifelse(V(g1)$sigla == "ODS", "orange", 
               ifelse(V(g1)$sigla == "ODB", "green",
               ifelse(V(g1)$sigla == "ODS", "darkblue",
               ifelse(V(g1)$sigla == "ODD", "pink",
               ifelse(V(g1)$sigla == "ODS", "orange", 
               ifelse(V(g1)$sigla == "ODE", "red" ,"dodgerblue"))))))


plot(g1, vertex.label.color = "black", 
     edge.color = 'gray77',
     vertex.size = 0.1,
     edge.arrow.size = 0.1,
     layout = layout_nicely(g1))


visIgraph(g1,idToLabel = TRUE)%>%
  visNodes(size = 30, shape = "circle") %>%
  visEdges(arrows ="all")%>%
  visLegend(enabled = TRUE)%>%

  visOptions(highlightNearest = TRUE, 
             nodesIdSelection = TRUE,
             manipulation = TRUE

  ) %>%
  visInteraction(keyboard = TRUE,
                 navigationButtons = TRUE,
                 dragNodes = TRUE,
                 hover = TRUE,
                 dragView = TRUE,
                 multiselect = TRUE,
                 selectConnectedEdges = TRUE,
                 tooltipStyle = 'position: fixed;visibility:hidden;padding: 5px;white-space: nowrap; font-family: cursive;font-size:18px;font-color:purple;background-color: red;',
                 zoomView = TRUE
  ) %>%
  visClusteringByConnection(nodes = 3)

'''Graph viewer without legend

0 个答案:

没有答案