graphviz#
graphviz is a popular graph visualization library that PyGraphistry can interface with. This allows you to leverage graphviz’s powerful layout algorithms, and optionally, static picture renderer. It is especially well-known for its “dot” layout algorithm for hierarchical and tree layouts of graphs with less than 10,000 nodes and edges.
- graphistry.plugins.graphviz.g_to_pgv(g, directed=True, strict=False, drop_unsanitary=False)#
- Parameters:
g (Plottable)
directed (bool)
strict (bool)
drop_unsanitary (bool)
- Return type:
None
- graphistry.plugins.graphviz.g_with_pgv_layout(g, graph)#
- graphistry.plugins.graphviz.layout_graphviz(self, prog='dot', args=None, directed=True, strict=False, graph_attr=None, node_attr=None, edge_attr=None, skip_styling=False, render_to_disk=False, path=None, format=None, drop_unsanitary=False)#
Use graphviz for layout, such as hierarchical trees and directed acycle graphs
Requires pygraphviz Python bindings and graphviz native libraries to be installed, see https://pygraphviz.github.io/documentation/stable/install.html
See PROGS for available layout algorithms
To render image to disk, set render=True
- Parameters:
self (Plottable) – Base graph
prog (
graphistry.plugins_types.graphviz_types.Prog
) – Layout algorithm - “dot”, “neato”, …args (Optional[str]) – Additional arguments to pass to the graphviz commandline for layout
directed (bool) – Whether the graph is directed (True, default) or undirected (False)
strict (bool) – Whether the graph is strict (True) or not (False, default)
graph_attr (Optional[Dict[
graphistry.plugins_types.graphviz_types.GraphAttr
, Any]]) – Graphviz graph attributes, see https://graphviz.org/docs/graph/node_attr (Optional[Dict[
graphistry.plugins_types.graphviz_types.NodeAttr
, Any]]) – Graphviz node attributes, see https://graphviz.org/docs/nodes/edge_attr (Optional[Dict[
graphistry.plugins_types.graphviz_types.EdgeAttr
, Any]]) – Graphviz edge attributes, see https://graphviz.org/docs/edges/skip_styling (bool) – Whether to skip applying default styling (False, default) or not (True)
render_to_disk (bool) – Whether to render the graph to disk (False, default) or not (True)
path (Optional[str]) – Path to save the rendered image when render_to_disk=True
format (Optional[
graphistry.plugins_types.graphviz_types.Format
]) – Format of the rendered image when render_to_disk=Truedrop_unsanitary (bool) – Whether to drop unsanitary attributes (False, default) or not (True), recommended for sensitive settings
- Returns:
Graph with layout and style settings applied, setting x/y
- Return type:
- Example: Dot layout for rigid hierarchical layout of trees and directed acyclic graphs
import graphistry edges = pd.DataFrame({'s': ['a','b','c','d'], 'd': ['b','c','d','e']}) g = graphistry.edges(edges, 's', 'd') g.layout_graphviz('dot').plot()
Example: Neato layout for organic layout of small graphs
import graphistry edges = pd.DataFrame({'s': ['a','b','c','d'], 'd': ['b','c','d','e']}) g = graphistry.edges(edges, 's', 'd') g.layout_graphviz('neato').plot()
Example: Set graphviz attributes at graph level
import graphistry edges = pd.DataFrame({'s': ['a','b','c','d'], 'd': ['b','c','d','e']}) g = graphistry.edges(edges, 's', 'd') g.layout_graphviz( prog='dot', graph_attr={ 'ratio': 10 } ).plot()
Example: Save rendered image to disk as a png
import graphistry edges = pd.DataFrame({'s': ['a','b','c','d'], 'd': ['b','c','d','e']}) g = graphistry.edges(edges, 's', 'd') g.layout_graphviz( 'dot', render_to_disk=True, path='graph.png', format='png' )
Example: Save rendered image to disk as a png with passthrough of rendering styles
import graphistry edges = pd.DataFrame({ 's': ['a','b','c','d'], 'd': ['b','c','d','e'], 'color': ['red', None, None, 'yellow'] }) nodes = pd.DataFrame({ 'n': ['a','b','c','d','e'], 'shape': ['circle', 'square', None, 'square', 'circle'] }) g = graphistry.edges(edges, 's', 'd') g.layout_graphviz( 'dot', render_to_disk=True, path='graph.png', format='png' )
- graphistry.plugins.graphviz.layout_graphviz_core(g, prog='dot', args=None, directed=True, strict=False, graph_attr=None, node_attr=None, edge_attr=None, drop_unsanitary=False)#
- Parameters:
g (Plottable)
prog (Literal['acyclic', 'ccomps', 'circo', 'dot', 'fdp', 'gc', 'gvcolor', 'gvpr', 'neato', 'nop', 'osage', 'patchwork', 'sccmap', 'sfdp', 'tred', 'twopi', 'unflatten'])
args (str | None)
directed (bool)
strict (bool)
graph_attr (Dict[Literal['_background', 'bb', 'beautify', 'bgcolor', 'center', 'charset', 'class', 'clusterrank', 'colorscheme', 'comment', 'compound', 'concentrate', 'Damping', 'defaultdist', 'dim', 'dimen', 'diredgeconstraints', 'dpi', 'epsilon', 'esep', 'fontcolor', 'fontname', 'fontnames', 'fontpath', 'fontsize', 'forcelabels', 'gradientangle', 'href', 'id', 'imagepath', 'inputscale', 'K', 'label', 'label_scheme', 'labeljust', 'labelloc', 'landscape', 'layerlistsep', 'layers', 'layerselect', 'layersep', 'layout', 'levels', 'levelsgap', 'lheight', 'linelength', 'lp', 'lwidth', 'margin', 'maxiter', 'mclimit', 'mindist', 'mode', 'model', 'newrank', 'nodesep', 'nojustify', 'normalize', 'notranslate', 'nslimit', 'nslimit1', 'oneblock', 'ordering', 'orientation', 'outputorder', 'overlap', 'overlap_scaling', 'overlap_shrink', 'pack', 'packmode', 'pad', 'page', 'pagedir', 'quadtree', 'quantum', 'rankdir', 'ranksep', 'ratio', 'remincross', 'repulsiveforce', 'resolution', 'root', 'rotate', 'rotation', 'scale', 'searchsize', 'sep', 'showboxes', 'size', 'smoothing', 'sortv', 'splines', 'start', 'style', 'stylesheet', 'target', 'TBbalance', 'tooltip', 'truecolor', 'URL', 'viewport', 'voro_margin', 'xdotversion'], ~typing.Any] | None)
node_attr (Dict[Literal['area', 'class', 'color', 'colorscheme', 'comment', 'distortion', 'fillcolor', 'fixedsize', 'fontcolor', 'fontname', 'fontsize', 'gradientangle', 'group', 'height', 'href', 'id', 'image', 'imagepos', 'imagescale', 'label', 'labelloc', 'layer', 'margin', 'nojustify', 'ordering', 'orientation', 'penwidth', 'peripheries', 'pin', 'pos', 'rects', 'regular', 'root', 'samplepoints', 'shape', 'shapefile', 'showboxes', 'sides', 'skew', 'sortv', 'style', 'target', 'tooltip', 'URL', 'vertices', 'width', 'xlabel', 'xlp', 'z'], ~typing.Any] | None)
edge_attr (Dict[Literal['arrowhead', 'arrowsize', 'arrowtail', 'class', 'color', 'colorscheme', 'comment', 'constraint', 'decorate', 'dir', 'edgehref', 'edgetarget', 'edgetooltip', 'edgeURL', 'fillcolor', 'fontcolor', 'fontname', 'fontsize', 'head_lp', 'headclip', 'headhref', 'headlabel', 'headport', 'headtarget', 'headtooltip', 'headURL', 'href', 'id', 'label', 'labelangle', 'labeldistance', 'labelfloat', 'labelfontcolor', 'labelfontname', 'labelfontsize', 'labelhref', 'labeltarget', 'labeltooltip', 'labelURL', 'layer', 'len', 'lhead', 'lp', 'ltail', 'minlen', 'nojustify', 'penwidth', 'pos', 'samehead', 'sametail', 'showboxes', 'style', 'tail_lp', 'tailclip', 'tailhref', 'taillabel', 'tailport', 'tailtarget', 'tailtooltip', 'tailURL', 'target', 'tooltip', 'URL', 'weight', 'xlabel', 'xlp'], ~typing.Any] | None)
drop_unsanitary (bool)
- Return type:
None
Constants
- graphistry.plugins_types.graphviz_types.EdgeAttr
alias of
Literal
[‘arrowhead’, ‘arrowsize’, ‘arrowtail’, ‘class’, ‘color’, ‘colorscheme’, ‘comment’, ‘constraint’, ‘decorate’, ‘dir’, ‘edgehref’, ‘edgetarget’, ‘edgetooltip’, ‘edgeURL’, ‘fillcolor’, ‘fontcolor’, ‘fontname’, ‘fontsize’, ‘head_lp’, ‘headclip’, ‘headhref’, ‘headlabel’, ‘headport’, ‘headtarget’, ‘headtooltip’, ‘headURL’, ‘href’, ‘id’, ‘label’, ‘labelangle’, ‘labeldistance’, ‘labelfloat’, ‘labelfontcolor’, ‘labelfontname’, ‘labelfontsize’, ‘labelhref’, ‘labeltarget’, ‘labeltooltip’, ‘labelURL’, ‘layer’, ‘len’, ‘lhead’, ‘lp’, ‘ltail’, ‘minlen’, ‘nojustify’, ‘penwidth’, ‘pos’, ‘samehead’, ‘sametail’, ‘showboxes’, ‘style’, ‘tail_lp’, ‘tailclip’, ‘tailhref’, ‘taillabel’, ‘tailport’, ‘tailtarget’, ‘tailtooltip’, ‘tailURL’, ‘target’, ‘tooltip’, ‘URL’, ‘weight’, ‘xlabel’, ‘xlp’]
- graphistry.plugins_types.graphviz_types.Format
alias of
Literal
[‘canon’, ‘cmap’, ‘cmapx’, ‘cmapx_np’, ‘dia’, ‘dot’, ‘fig’, ‘gd’, ‘gd2’, ‘gif’, ‘hpgl’, ‘imap’, ‘imap_np’, ‘ismap’, ‘jpe’, ‘jpeg’, ‘jpg’, ‘mif’, ‘mp’, ‘pcl’, ‘pdf’, ‘pic’, ‘plain’, ‘plain-ext’, ‘png’, ‘ps’, ‘ps2’, ‘svg’, ‘svgz’, ‘vml’, ‘vmlz’, ‘vrml’, ‘vtx’, ‘wbmp’, ‘xdot’, ‘xlib’]
- graphistry.plugins_types.graphviz_types.GraphAttr
alias of
Literal
[‘_background’, ‘bb’, ‘beautify’, ‘bgcolor’, ‘center’, ‘charset’, ‘class’, ‘clusterrank’, ‘colorscheme’, ‘comment’, ‘compound’, ‘concentrate’, ‘Damping’, ‘defaultdist’, ‘dim’, ‘dimen’, ‘diredgeconstraints’, ‘dpi’, ‘epsilon’, ‘esep’, ‘fontcolor’, ‘fontname’, ‘fontnames’, ‘fontpath’, ‘fontsize’, ‘forcelabels’, ‘gradientangle’, ‘href’, ‘id’, ‘imagepath’, ‘inputscale’, ‘K’, ‘label’, ‘label_scheme’, ‘labeljust’, ‘labelloc’, ‘landscape’, ‘layerlistsep’, ‘layers’, ‘layerselect’, ‘layersep’, ‘layout’, ‘levels’, ‘levelsgap’, ‘lheight’, ‘linelength’, ‘lp’, ‘lwidth’, ‘margin’, ‘maxiter’, ‘mclimit’, ‘mindist’, ‘mode’, ‘model’, ‘newrank’, ‘nodesep’, ‘nojustify’, ‘normalize’, ‘notranslate’, ‘nslimit’, ‘nslimit1’, ‘oneblock’, ‘ordering’, ‘orientation’, ‘outputorder’, ‘overlap’, ‘overlap_scaling’, ‘overlap_shrink’, ‘pack’, ‘packmode’, ‘pad’, ‘page’, ‘pagedir’, ‘quadtree’, ‘quantum’, ‘rankdir’, ‘ranksep’, ‘ratio’, ‘remincross’, ‘repulsiveforce’, ‘resolution’, ‘root’, ‘rotate’, ‘rotation’, ‘scale’, ‘searchsize’, ‘sep’, ‘showboxes’, ‘size’, ‘smoothing’, ‘sortv’, ‘splines’, ‘start’, ‘style’, ‘stylesheet’, ‘target’, ‘TBbalance’, ‘tooltip’, ‘truecolor’, ‘URL’, ‘viewport’, ‘voro_margin’, ‘xdotversion’]
- graphistry.plugins_types.graphviz_types.NodeAttr
alias of
Literal
[‘area’, ‘class’, ‘color’, ‘colorscheme’, ‘comment’, ‘distortion’, ‘fillcolor’, ‘fixedsize’, ‘fontcolor’, ‘fontname’, ‘fontsize’, ‘gradientangle’, ‘group’, ‘height’, ‘href’, ‘id’, ‘image’, ‘imagepos’, ‘imagescale’, ‘label’, ‘labelloc’, ‘layer’, ‘margin’, ‘nojustify’, ‘ordering’, ‘orientation’, ‘penwidth’, ‘peripheries’, ‘pin’, ‘pos’, ‘rects’, ‘regular’, ‘root’, ‘samplepoints’, ‘shape’, ‘shapefile’, ‘showboxes’, ‘sides’, ‘skew’, ‘sortv’, ‘style’, ‘target’, ‘tooltip’, ‘URL’, ‘vertices’, ‘width’, ‘xlabel’, ‘xlp’, ‘z’]
- graphistry.plugins_types.graphviz_types.Prog
alias of
Literal
[‘acyclic’, ‘ccomps’, ‘circo’, ‘dot’, ‘fdp’, ‘gc’, ‘gvcolor’, ‘gvpr’, ‘neato’, ‘nop’, ‘osage’, ‘patchwork’, ‘sccmap’, ‘sfdp’, ‘tred’, ‘twopi’, ‘unflatten’]
- graphistry.plugins_types.graphviz_types.EDGE_ATTRS typing.List[graphistry.plugins_types.graphviz_types.EdgeAttr]#
Built-in mutable sequence.
If no argument is given, the constructor creates a new empty list. The argument must be an iterable if specified.
- graphistry.plugins_types.graphviz_types.FORMATS typing.List[graphistry.plugins_types.graphviz_types.Format]#
Built-in mutable sequence.
If no argument is given, the constructor creates a new empty list. The argument must be an iterable if specified.
- graphistry.plugins_types.graphviz_types.GRAPH_ATTRS typing.List[graphistry.plugins_types.graphviz_types.GraphAttr]#
Built-in mutable sequence.
If no argument is given, the constructor creates a new empty list. The argument must be an iterable if specified.
- graphistry.plugins_types.graphviz_types.NODE_ATTRS typing.List[graphistry.plugins_types.graphviz_types.NodeAttr]#
Built-in mutable sequence.
If no argument is given, the constructor creates a new empty list. The argument must be an iterable if specified.
- graphistry.plugins_types.graphviz_types.PROGS typing.List[graphistry.plugins_types.graphviz_types.Prog]#
Built-in mutable sequence.
If no argument is given, the constructor creates a new empty list. The argument must be an iterable if specified.