Title: | Visualize Networks using 'roughjs' |
---|---|
Description: | Visualize networks using the 'javascript' library 'roughjs'. This allows to draw sketchy, hand-drawn-like networks. |
Authors: | David Schoch [aut, cre] |
Maintainer: | David Schoch <[email protected]> |
License: | MIT + file LICENSE |
Version: | 1.0.1 |
Built: | 2024-11-22 05:37:54 UTC |
Source: | https://github.com/schochastics/roughnet |
plot a network using rough.js
roughnet( g, roughness = c(1, 1), bowing = c(1, 1), font = "30px Arial", width = NULL, height = NULL, elementId = NULL, chunk_name = "canvas" )
roughnet( g, roughness = c(1, 1), bowing = c(1, 1), font = "30px Arial", width = NULL, height = NULL, elementId = NULL, chunk_name = "canvas" )
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 |
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
htmlwidget containing the drawn network
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)
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)
Save roughnet plot to file
save_roughnet(rnet, file, background = "white")
save_roughnet(rnet, file, background = "white")
rnet |
result from calling the function |
file |
filename |
background |
string giving the html background color |
No return value, called for side effect