API manual

Luxor.midpointMethod
midpoint(a::Node, b::Node)

Get the midpoint of two nodes. Returns a Node of shape :dot.

source
LuxorGraphPlot.boundaryMethod
boundary(n::Node, s::String)
boundary(n::Node, angle::Real)

Get the boundary point of a node in a direction. The direction can be specified by a string or an angle. Possible strings are: "left", "right", "top", "bottom", "topright", "topleft", "bottomleft", "bottomright".

source
LuxorGraphPlot.box!Method
box!([nodestore, ]args...; kwargs...) = push!(nodestore, boxnode(args...; kwargs...))

Add a box shaped node to the nodestore. Please refer to boxnode for more information. If nodestore is not provided, the current nodestore is used.

source
LuxorGraphPlot.circle!Method
circle!([nodestore, ]args...; kwargs...) = push!(nodestore, circlenode(args...; kwargs...))

Add a circle shaped node to the nodestore. Please refer to circlenode for more information. If nodestore is not provided, the current nodestore is used.

source
LuxorGraphPlot.dot!Method
dot!([nodestore, ]args...; kwargs...) = push!(nodestore, dotnode(args...; kwargs...))

Add a dot shaped node to the nodestore. Please refer to dotnode for more information. If nodestore is not provided, the current nodestore is used.

source
LuxorGraphPlot.ellipse!Method
ellipse!([nodestore, ]args...; kwargs...) = push!(nodestore, ellipsenode(args...; kwargs...))

Add a ellipse shaped node to the nodestore. Please refer to ellipsenode for more information. If nodestore is not provided, the current nodestore is used.

source
LuxorGraphPlot.line!Method
line!([nodestore, ]args...; kwargs...) = push!(nodestore, linenode(args...; kwargs...))

Add a line shaped node to the nodestore. Please refer to linenode for more information. If nodestore is not provided, the current nodestore is used.

source
LuxorGraphPlot.nodestoreMethod
nodestore(f)

Create a NodeStore context, such that box!, circle!, polygon!, dot! and line! will add nodes to the nodestore. The nodestore is passed to the function f as an argument.

Example

julia> using LuxorGraphPlot, LuxorGraphPlot.Luxor

julia> nodestore() do ns
    box = box!(ns, (100, 100), 100, 100)
    circle = circle!(ns, (200, 200), 50)
    with_nodes(ns) do
        stroke(box)
        stroke(circle)
        Luxor.line(topright(box), circle)
    end
end
source
LuxorGraphPlot.offsetMethod
offset(n::Node, p::Union{Tuple,Point})
offset(n::Node, direction, distance)
offset(n::Node, direction::Node, distance)

Offset a node towards a direction or another node. The direction can be specified by a tuple, a Point or a Node.

source
LuxorGraphPlot.polygon!Method
polygon!([nodestore, ]args...; kwargs...) = push!(nodestore, polygonnode(args...; kwargs...))

Add a polygon shaped node to the nodestore. Please refer to polygonnode for more information. If nodestore is not provided, the current nodestore is used.

source
LuxorGraphPlot.show_galleryMethod
show_gallery([f, ]stores::AbstractMatrix{GraphViz};
    kwargs...
    )

Show a gallery of graphs in VSCode, Pluto or Jupyter notebook, or save it to a file.

Positional arguments

  • f is a function that returns extra Luxor plotting statements.
  • stores is a matrix of GraphViz instances.

Keyword arguments

  • config is a GraphDisplayConfig instance.

  • padding_left::Int = 10, the padding on the left side of the drawing

  • padding_right::Int = 10, the padding on the right side of the drawing

  • padding_top::Int = 10, the padding on the top side of the drawing

  • padding_bottom::Int = 10, the padding on the bottom side of the drawing

  • format is the output format, which can be :svg, :png or :pdf.

  • filename is a string as the output filename.

source
LuxorGraphPlot.show_graphMethod
show_graph([f, ]graph::AbstractGraph;
    kwargs...
    )

Show a graph in VSCode, Pluto or Jupyter notebook, or save it to a file.

Positional arguments

  • f is a function that returns extra Luxor plotting statements.
  • graph is a graph instance.
  • locs is a vector of tuples for specifying the vertex locations, or a AbstractLayout instance.

Keyword arguments

  • config is a GraphDisplayConfig instance.

  • vertex_colors is a vector of color strings for specifying vertex fill colors.

  • vertex_sizes is a vector of real numbers for specifying vertex sizes.

  • vertex_shapes is a vector of strings for specifying vertex shapes, the string should be "circle" or "box".

  • vertex_stroke_colors is a vector of color strings for specifying vertex stroke colors.

  • vertex_text_colors is a vector of color strings for specifying vertex text colors.

  • edge_colors is a vector of color strings for specifying edge colors.

  • texts is a vector of strings for labeling vertices.

  • padding_left::Int = 10, the padding on the left side of the drawing

  • padding_right::Int = 10, the padding on the right side of the drawing

  • padding_top::Int = 10, the padding on the top side of the drawing

  • padding_bottom::Int = 10, the padding on the bottom side of the drawing

  • format is the output format, which can be :svg, :png or :pdf.

  • filename is a string as the output filename.

Example

julia> using Graphs, LuxorGraphPlot

julia> show_graph(smallgraph(:petersen); format=:png, vertex_colors=rand(["blue", "red"], 10));
source
LuxorGraphPlot.with_nodesMethod
with_nodes(f[, nodestore]; kwargs...)

Create a drawing with the nodes in the nodestore. The bounding box of the drawing is determined by the bounding box of the nodes in the nodestore. If nodestore is not provided, the current nodestore is used.

Keyword arguments

  • padding_left::Int=10: Padding on the left side of the drawing.
  • padding_right::Int=10: Padding on the right side of the drawing.
  • padding_top::Int=10: Padding on the top side of the drawing.
  • padding_bottom::Int=10: Padding on the bottom side of the drawing.
  • format::Symbol=:svg: The format of the drawing. Available formats are :png, :pdf, :svg...
  • filename::String=nothing: The filename of the drawing. If nothing, a temporary file is created.
  • background::String="white": The background color of the drawing.
source
LuxorGraphPlot.ConnectionType
Connection(start, stop; isarrow=false, mode=:exact, arrowprops=Dict{Symbol, Any}(), control_points=Point[], smoothprops=Dict{Symbol, Any}())

Create a connection between two nodes. The connection can be a line, a curve, a bezier curve, a smooth curve or a zig-zag line.

Required Arguments

  • start::Node: the start node
  • stop::Node: the stop node

Optional Keyword Arguments

  • isarrow=false: whether to draw an arrow at the end of the connection
  • mode=:exact: the mode to get the connection point, can be :exact or :natural
  • arrowprops=Dict{Symbol, Any}(): the properties of the arrow
  • control_points=Point[]: the control points for the connection
  • smoothprops=Dict{Symbol, Any}(): the properties of the smooth curve
source
LuxorGraphPlot.GraphDisplayConfigType
GraphDisplayConfig

The configuration for graph display.

Keyword arguments

  • locs is a vector of tuples for specifying the vertex locations.

  • edges is a vector of tuples for specifying the edges.

  • fontsize::Float64 = 12.0, the font size

  • fontface::String = "", the font face, leave empty to follow system

  • vertex_text_color = "black", the default text color

  • vertex_stroke_color = "black", the default stroke color for vertices

  • vertex_color = "transparent", the default default fill color for vertices

  • vertex_size::Float64 = 10.0, the default vertex size

  • vertex_shape::Symbol = :circle, the default vertex shape, which can be :circle, :box or :dot

  • vertex_line_width::Float64 = 1, the default vertex stroke line width

  • vertex_line_style::String = "solid", the line style of vertex stroke, which can be one of ["solid", "dotted", "dot", "dotdashed", "longdashed", "shortdashed", "dash", "dashed", "dotdotdashed", "dotdotdotdashed"]

  • edge_color = "black", the default edge color

  • edge_line_width::Float64 = 1, the default line width

  • edge_style::String = "solid", the line style of edges, which can be one of ["solid", "dotted", "dot", "dotdashed", "longdashed", "shortdashed", "dash", "dashed", "dotdotdashed", "dotdotdotdashed"]

source
LuxorGraphPlot.GraphVizType
GraphViz

The struct for storing graph visualization information.

Keyword arguments

  • vertex_colors is a vector of color strings for specifying vertex fill colors.
  • vertex_sizes is a vector of real numbers for specifying vertex sizes.
  • vertex_shapes is a vector of strings for specifying vertex shapes, the string should be "circle" or "box".
  • vertex_stroke_colors is a vector of color strings for specifying vertex stroke colors.
  • vertex_text_colors is a vector of color strings for specifying vertex text colors.
  • edge_colors is a vector of color strings for specifying edge colors.
  • texts is a vector of strings for labeling vertices.
source
LuxorGraphPlot.NodeType
Node(shape::Symbol, loc; props...)

Create a node with a shape and a location. The shape can be :circle, :ellipse, :box, :polygon, :line or :dot.

Required Keyword Arguments

  • ellipse: [:width, :height]
  • circle: [:radius]
  • line: [:relpath]
  • dot: Symbol[]
  • polygon: [:relpath]
  • box: [:width, :height]

Optional Keyword Arguments

  • ellipse: Dict{Symbol, Any}()
  • circle: Dict{Symbol, Any}()
  • line: Dict{Symbol, Any}(:arrowstyle => "-")
  • dot: Dict{Symbol, Any}()
  • polygon: Dict{Symbol, Any}(:smooth => 0, :close => true)
  • box: Dict{Symbol, Any}(:smooth => 0)
source
LuxorGraphPlot.Layouts.LayeredSpringLayoutMethod
LayeredSpringLayout(; zlocs, optimal_distance, aspect_ration=0.2)

Create a layered spring layout.

Keyword Arguments

  • zlocs: the z-axis locations
  • optimal_distance::Float64: the optimal distance between vertices
  • aspect_ration::Float64: the aspect ratio of the z-axis
  • α0::Float64: the initial moving speed
  • maxiter::Int: the maximum number of iterations
source
LuxorGraphPlot.Layouts.LayeredStressLayoutMethod
LayeredStressLayout(; zlocs, optimal_distance, aspect_ration=0.2)

Create a layered stress layout.

Keyword Arguments

  • zlocs: the z-axis locations
  • optimal_distance::Float64: the optimal distance between vertices
  • aspect_ration::Float64: the aspect ratio of the z-axis
  • maxiter::Int: the maximum number of iterations
  • rtol::Float64: the absolute tolerance
source
LuxorGraphPlot.Layouts.spring_layoutMethod
spring_layout(g::AbstractGraph;
                   locs=nothing,
                   optimal_distance=50.0,   # the optimal vertex distance
                   maxiter=100,
                   α0=2*optimal_distance,  # initial moving speed
                   mask::AbstractVector{Bool}=trues(nv(g))   # mask for which to relocate
                   )

Spring layout for graph plotting, returns a vector of vertex locations.

Note

This function is copied from GraphPlot.jl, where you can find more information about his function.

source
LuxorGraphPlot.Layouts.stressmajorize_layoutMethod
stressmajorize_layout(g::AbstractGraph;
                           locs=rand_points_2d(nv(g)),
                           w=nothing,
                           optimal_distance=50.0,   # the optimal vertex distance
                           maxiter = 400 * nv(g)^2,
                           rtol=1e-2,
                           )

Stress majorization layout for graph plotting, returns a vector of vertex locations.

References

  • https://github.com/JuliaGraphs/GraphPlot.jl/blob/e97063729fd9047c4482070870e17ed1d95a3211/src/stress.jl
source
LuxorGraphPlot.Layouts.LayeredType
Layered <: AbstractLayout

Layered version of a parent layout algorithm.

Fields

  • parent::LT: the parent layout algorithm
  • zlocs::Vector{T}: the z-axis locations
  • aspect_ratio::Float64: the aspect ratio of the z-axis
source
LuxorGraphPlot.Layouts.SpectralLayoutType
SpectralLayout <: AbstractLayout

A layout algorithm based on spectral graph theory.

Fields

  • optimal_distance::Float64: the optimal distance between vertices
  • dimension::Int: the number of dimensions
source
LuxorGraphPlot.Layouts.SpringLayoutType
SpringLayout <: AbstractLayout

A layout algorithm based on a spring model.

Fields

  • optimal_distance::Float64: the optimal distance between vertices
  • maxiter::Int: the maximum number of iterations
  • α0::Float64: the initial moving speed
  • meta::Dict{Symbol, Any}: graph dependent meta information, including
    • initial_locs: initial vertex locations
    • mask: boolean mask for which vertices to relocate
source
LuxorGraphPlot.Layouts.StressLayoutType
StressLayout <: AbstractLayout

A layout algorithm based on stress majorization.

Fields

  • optimal_distance::Float64: the optimal distance between vertices
  • maxiter::Int: the maximum number of iterations
  • rtol::Float64: the absolute tolerance
  • initial_locs: initial vertex locations
  • mask: boolean mask for which vertices to relocate
  • meta::Dict{Symbol, Any}: graph dependent meta information, including
    • initial_locs: initial vertex locations
    • mask: boolean mask for which vertices to relocate
source