roughnet {roughnet} | R Documentation |
Create a rough network
Description
plot a network using rough.js
Usage
roughnet(
g,
roughness = c(1, 1),
bowing = c(1, 1),
font = "30px Arial",
width = NULL,
height = NULL,
elementId = NULL,
chunk_name = "canvas"
)
Arguments
g |
igraph object |
roughness |
numeric vector for roughness of vertices and edges |
bowing |
numeric vector for bowing of vertices and edges |
font |
font size and font family for labels |
width |
width |
height |
height |
elementId |
DOM id |
chunk_name |
markdown specific |
Details
the function recognizes the following attributes Vertex attributes (e.g. V(g)$shape):
-
shape one of "circle", "rectangle", "heart", "air", "earth", "fire", "water"
-
fill vertex fill color
-
color vertex stroke color
-
stroke stroke size
-
fillstyle one of "hachure", "solid", "zigzag", "cross-hatch", "dots", "sunburst", "dashed", "zigzag-line"
-
size vertex size
-
label vertex label
-
pos position of vertex label (c)enter, (n)orth, (e)ast, (s)outh, (w)est
Edge attributes (e.g. E(g)$color):
-
color edge color
-
width edge width
Default values are used if one of the attributes is not found.
The result of a roughnet call can be printed to file with save_roughnet()
More details on roughjs can be found on https://github.com/rough-stuff/rough/wiki
Value
htmlwidget containing the drawn network
Examples
library(igraph)
g <- make_graph("Zachary")
V(g)$shape <- "circle"
V(g)$shape[c(1, 34)] <- "rectangle"
V(g)$fill <- c("#E41A1C", "#377EB8", "#4DAF4A", "#984EA3")[membership(cluster_louvain(g))]
V(g)$fillstyle <- c("hachure", "zigzag", "cross-hatch", "dots")[membership(cluster_louvain(g))]
V(g)$color <- "black"
V(g)$size <- 30
V(g)$stroke <- 2
E(g)$color <- "#AEAEAE"
roughnet(g, width = 960, height = 600)