# Graphics

`Catlab.Graphics.GraphvizGraphs`

— ModuleGraphviz support for Catlab's graph types.

`Catlab.Graphics.GraphvizGraphs.parse_graphviz`

— MethodParse Graphviz output in JSON format.

Returns a property graph with graph layout and other metadata. Each node has a position and size.

All units are in points. Note that Graphviz has 72 points per inch.

`Catlab.Graphics.GraphvizGraphs.to_graphviz`

— MethodConvert a property graph to a Graphviz graph.

This method is usually more convenient than direct AST manipulation for creating simple Graphviz graphs. For more advanced features, like nested subgraphs, you must use the Graphviz AST.

`Catlab.Graphics.GraphvizGraphs.to_graphviz`

— MethodConvert a graph to a Graphviz graph.

A simple default style is applied. For more control over the visual appearance, first convert the graph to a property graph, define the Graphviz attributes as needed, and then convert to a Graphviz graph.

`Catlab.Graphics.ComposeWiringDiagrams`

— ModuleDraw wiring diagrams using Compose.jl.

`Catlab.Graphics.ComposeWiringDiagrams.ComposePicture`

— TypeA Compose context together with a given width and height.

We need this type because contexts have no notion of size or aspect ratio, but wiring diagram layouts have fixed aspect ratios.

`Catlab.Graphics.ComposeWiringDiagrams.layout_to_composejl`

— MethodDraw a wiring diagram in Compose.jl using the given layout.

`Catlab.Graphics.ComposeWiringDiagrams.to_composejl`

— MethodDraw a wiring diagram in Compose.jl.

`Catlab.Graphics.GraphvizWiringDiagrams`

— ModuleLay out and draw wiring diagrams using Graphviz.

This module requires Graphviz v2.42 or higher.

`Catlab.Graphics.GraphvizGraphs.to_graphviz`

— MethodDraw an undirected wiring diagram using Graphviz.

Creates an undirected, bipartite Graphviz graph, with the boxes and outer ports of the diagram becoming nodes of one kind and the junctions of the diagram becoming nodes of the second kind.

**Arguments**

`graph_name="G"`

: name of Graphviz graph`prog="neato"`

: Graphviz program, usually "neato" or "fdp"`box_labels=false`

: if boolean, whether to label boxes with their number; if a symbol, name of data attribute for box label`port_labels=false`

: whether to label ports with their number`junction_labels=false`

: if boolean, whether to label junctions with their number; if a symbol, name of data attribute for junction label`junction_size="0.075"`

: size of junction nodes, in inches`implicit_junctions=false`

: whether to represent a junction implicity as a wire when it has exactly two incident ports`graph_attrs=Dict()`

: top-level graph attributes`node_attrs=Dict()`

: top-level node attributes`edge_attrs=Dict()`

: top-level edge attributes

`Catlab.Graphics.GraphvizGraphs.to_graphviz`

— MethodDraw a circular port graph using Graphviz.

Creates a Graphviz graph. Ports are currently not respected in the image, but the port index for each box can be displayed to provide clarification.

**Arguments**

`graph_name="G"`

: name of Graphviz graph`prog="neato"`

: Graphviz program, usually "neato" or "fdp"`box_labels=false`

: whether to label boxes with their number`port_labels=false`

: whether to label ports with their number`graph_attrs=Dict()`

: top-level graph attributes`node_attrs=Dict()`

: top-level node attributes`edge_attrs=Dict()`

: top-level edge attributes

TODO: The lack of ports might be able to be resolved by introducing an extra node per port which is connected to its box with an edge of length 0.

`Catlab.Graphics.GraphvizGraphs.to_graphviz`

— MethodDraw a wiring diagram using Graphviz.

The input can also be a morphism expression, in which case it is first converted into a wiring diagram. This function requires Graphviz v2.42 or higher.

**Arguments**

`graph_name="G"`

: name of Graphviz digraph`orientation=TopToBottom`

: orientation of layout. One of`LeftToRight`

,`RightToLeft`

,`TopToBottom`

, or`BottomToTop`

.`node_labels=true`

: whether to label the nodes`labels=false`

: whether to label the edges`label_attr=:label`

: what kind of edge label to use (if`labels`

is true). One of`:label`

,`:xlabel`

,`:headlabel`

, or`:taillabel`

.`port_size="24"`

: minimum size of ports on box, in points`junction_size="0.05"`

: size of junction nodes, in inches`outer_ports=true`

: whether to display the outer box's input and output ports. If disabled, no incoming or outgoing wires will be shown either!`anchor_outer_ports=true`

: whether to enforce ordering of the outer box's input and output, i.e., ordering of the incoming and outgoing wires`graph_attrs=Dict()`

: top-level graph attributes`node_attrs=Dict()`

: top-level node attributes`edge_attrs=Dict()`

: top-level edge attributes`cell_attrs=Dict()`

: main cell attributes in node HTML-like label

`Catlab.Graphics.GraphvizWiringDiagrams.graphviz_layout`

— MethodLay out directed wiring diagram using Graphviz.

Note: At this time, only the positions and sizes of the boxes, and the positions of the outer ports, are used. The positions of the box ports and the splines for the wires are ignored.

`Catlab.Graphics.TikZWiringDiagrams`

— ModuleDraw wiring diagrams using TikZ.

`Catlab.Graphics.TikZWiringDiagrams.layout_to_tikz`

— MethodDraw a wiring diagram in TikZ using the given layout.

`Catlab.Graphics.TikZWiringDiagrams.to_tikz`

— MethodDraw a wiring diagram in TikZ.

`Catlab.Graphics.WiringDiagramLayouts`

— ModuleBackend-agnostic layout of wiring diagrams via morphism expressions.

This module lays out wiring diagrams for visualization, independent of any specific graphics system. It uses the structure of a morphism expression to determine the layout. Thus, the first step of the algorithm is to convert the wiring diagram to a symbolic expression, using the submodule `WiringDiagrams.Expressions`

. Morphism expressions may also be given directly.

`Catlab.Graphics.WiringDiagramLayouts.LayoutOrientation`

— TypeOrientation of wiring diagram.

`Catlab.Graphics.WiringDiagramLayouts.layout_box`

— MethodLay out a box and its ports.

By default the box is rectangular, but other shapes are also supported.

`Catlab.Graphics.WiringDiagramLayouts.layout_diagram`

— MethodLay out a wiring diagram or morphism expression for visualization.

If a wiring diagram is given, it is first to converted to a morphism expression.

The layout is calculated with respect to a cartesian coordinate system with origin at the center of the diagram and the positive y-axis pointing *downwards*. Box positions are relative to their centers. All positions and sizes are dimensionless (unitless).