Karnak.drawgraph
— MethodDraw a graph g
using coordinates in layout
to fit in a Luxor boundingbox
.
Keyword arguments
boundingbox::BoundingBox graph fits inside this BB
layout Point[] or function
margin default 30
edgelist draw only these edges
vertexfunction(vtx, coords) -> draw vertices
edgefunction(edgenumber, edgesrc, edgedest, from, to) -> draw edges
Or use these individual keywords:
• vertexlabels f • edgelabels f
• vertexshapes f • edgelines f
• vertexshapesizes f • edgelist
• vertexshaperotations f • edgecurvature
• vertexstrokecolors f • edgestrokecolors f
• vertexstrokeweights f • edgestrokeweights f
• vertexfillcolors f • edgedashpatterns
• vertexlabeltextcolors • edgegaps
• vertexlabelfontsizes • edgelabelrotations f
• vertexlabelfontfaces • edgelabelcolors
• vertexlabelrotations
• vertexlabeloffsetangles
• vertexlabeloffsetdistances
layout
- the layout method or coordinates to be used. Examples:
layout = squaregrid
layout = shell
layout = vcat(
between.(O + (-W/2, H), O + (W/2, H), range(0, 1, length=N)),
between.(O + (-W/2, -H), O + (W/2, -H), range(0, 1, length=N)))
layout = stress
layout = (g) -> spectral(adjacency_matrix(g), dim=2)
layout = shell ∘ adjacency_matrix
layout = (g) -> sfdp(g, Ptype=Float64, dim=2, tol=0.05, C=0.4, K=2)
layout = Shell(nlist=[6:10,]) # inner shell for vertices 6 to 10
layout = squaregrid
the_positions = [(pt.x, pt.y) for pt in randompointarray(BoundingBox(), 50)[1:nv(G)]]
the_weights = rand(1:20, nv(G), nv(G))
layout=Stress(initialpos = the_positions,
iterations = 30,
weights = the_weights)
layout = Stress(iterations = 100, weights = M) # M is matrix of weights
layout = Spring(iterations = 200, initialtemp = 2.5)
Refer to the NetworkLayout.jl documentation for more.
Extended help
Functions to control every aspect of vertex and edge:
vertexfunction(vertex, coordinates)
->
A function vertexfunction(vertex, coordinates)
that completely specifies the appearance of every vertex. None of the other vertex- keyword arguments will be used. Example:
vertexfunction = (v, c) -> ngon(c[v], 30, 6, 0, :fill)
edgefunction(edgenumber, edgesrc, edgedest, from, to)
->
A function edgefunction(edgenumber, from, to, edgesrc, edgedest)
that completely specifies the appearance of every edge. None of the other edge- keyword arguments are used.
Vertex options
vertexfillcolors
: Array | Colorant | :none | Function (vtx) -> the colors for vertex
vertexlabels
: Array | Range " string "|:none | Function (vtx) -> return label for each vertex
The text labels for each vertex. Vertex labels are not drawn by default.
vertexshapes
: Array | Range | :circle | :square | :none | Function (vtx) ->
Use shape for vertex. If function, vtx
is vertex number, using current vertex rotation (vertextshaperotations
), make your own graphic shapes. The function can override rotations and colors.
vertexshapesizes
: Array | Range | Real | Function
The size of each vertex shape for :circle :square...
vertexshaperotations
: Array | Range | Real | Function
the rotation of shapes,
vertexstrokecolors
: Array | Colorant | :none | Function (vtx) -> colorant
vertexstrokeweights
: Array | Range | :none | Function
vertexfillcolors
: Array | Colorant | :none | Function (vtx) -> colorant
vertexlabeltextcolors
vertexlabelfontsizes
vertexlabelfontfaces
vertexlabelrotations
vertexlabeloffsetangles
vertexlabeldistances
Edge options
edgelist
: Array | Edge iterator
A list of Edges (Graphs.EdgeIterator) to be drawn. Takes prioity over edgelines
.
edgelines
: Array | Range | Int| :none | Function (edgenumber, edgesrc, edgedest, from, to) ->
Edge lines to be drawn.
edgelabels
: Array | Range | Dict | Function (edgenumber, edgesrc, edgedest, from::Point, to::Point) ->
edgecurvature=0.0
edgestrokecolors
: Array | Colorant | Function (n, s, d, from, to)` -> colorant
Colors of edges. Function can be edgestrokecolors = (n, s, d, f, t) -> HSB(rescale(n, 1, ne(g), 0, 360), 0.9, 0.8))
edgestrokeweights
Array | Range | Real | Function (n, s, d, from, to)` -> n
edgedashpatterns
: Array of Arrays | Array
The dash pattern or an array of dash patterns for the edge lines. Dash patterns might be eg [[10, 30], [1]]
. Numbers alternate between lines and spaces.
edgegaps
:
The gaps from vertex center to arrow tip
edgelabelcolors
The colors of the label text
edgelabelrotations
: A | Range | function edgelabelrotations = (n, s, d, f, t) -> angle
The rotation of the label text
edgelabelfontsizes
edgelabelfontfaces