Title: | Visualize Networks using 'roughjs' |
Version: | 1.0.1 |
Description: | Visualize networks using the 'javascript' library 'roughjs'. This allows to draw sketchy, hand-drawn-like networks. |
License: | MIT + file LICENSE |
URL: | https://github.com/schochastics/roughnet/ |
BugReports: | https://github.com/schochastics/roughnet/issues |
Encoding: | UTF-8 |
RoxygenNote: | 7.2.0 |
Imports: | igraph, graphlayouts, jsonlite, htmlwidgets |
Suggests: | pagedown |
NeedsCompilation: | no |
Packaged: | 2022-12-06 20:07:26 UTC; david |
Author: | David Schoch |
Maintainer: | David Schoch <david@schochastics.net> |
Repository: | CRAN |
Date/Publication: | 2022-12-06 20:20:02 UTC |
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)
Save roughnet plot to file
Description
Save roughnet plot to file
Usage
save_roughnet(rnet, file, background = "white")
Arguments
rnet |
result from calling the function |
file |
filename |
background |
string giving the html background color |
Value
No return value, called for side effect