cairo_draw

Contents

cairo_draw#

graph_tool.draw.cairo_draw(g, pos, cr, vprops=None, eprops=None, vorder=None, eorder=None, nodesfirst=False, vcmap=None, vcnorm=None, ecmap=None, ecnorm=None, loop_angle=nan, parallel_distance=None, res=0, size_units='output', max_render_time=-1, **kwargs)[git][source]#

Draw a graph to a cairo.Context.

Parameters:
gGraph

Graph to be drawn.

posVertexPropertyMap

Vector-valued vertex property map containing the x and y coordinates of the vertices.

crContext

A Context instance. The raster images that are embedded in vector output (see gradient_render in the edge properties of graph_draw()) have the fallback resolution of its target surface, which is 300 ppi by default, and can be changed with cairo.Surface.set_fallback_resolution().

vpropsdict (optional, default: None)

Dictionary with the vertex properties. Individual properties may also be given via the vertex_<prop-name> parameters, where <prop-name> is the name of the property.

epropsdict (optional, default: None)

Dictionary with the edge properties. Individual properties may also be given via the edge_<prop-name> parameters, where <prop-name> is the name of the property.

vorderVertexPropertyMap (optional, default: None)

If provided, defines the relative order in which the vertices are drawn.

eorderEdgePropertyMap (optional, default: None)

If provided, defines the relative order in which the edges are drawn.

nodesfirstbool (optional, default: False)

If True, the vertices are drawn first, otherwise the edges are.

vcmapmatplotlib.colors.Colormap or tuple (optional, default: None)

Vertex color map. Optionally, this may be a (matplotlib.colors.Colormap, alpha) tuple. The values of scalar property maps are normalized to \([0, 1]\) (see vcnorm), except for integer or boolean values with a matplotlib.colors.ListedColormap of fewer than 256 colors (a qualitative colormap), in which case the distinct values are assigned the colors of the list in turn.

vcnormmatplotlib.colors.Normalize (optional, default: None)

An object which, when called, normalizes vertex property values into the \([0.0, 1.0]\) interval, before passing to the vcmap colormap.

ecmapmatplotlib.colors.Colormap or tuple (optional, default: None)

Edge color map. Optionally, this may be a (matplotlib.colors.Colormap, alpha) tuple. The values are mapped as for vcmap.

ecnormmatplotlib.colors.Normalize (optional, default: None)

An object which, when called, normalizes edge property values into the \([0.0, 1.0]\) interval, before passing to the ecmap colormap.

loop_anglefloat or VertexPropertyMap (optional, default: numpy.nan)

Angle used to draw self-loops. If nan is given, they will be placed radially from the center of the layout.

parallel_distancefloat (optional, default: None)

Distance used between parallel edges. If not provided, it will be determined automatically.

resfloat (optional, default: 0.)

If shape sizes fall below this value, simplified drawing is used.

size_units"output" or "layout" (optional, default: "output")

Units of the vertex and edge sizes (vertex and marker sizes, pen widths, font sizes, text distances and offsets, dash patterns). If "output", they are in units of the output (e.g. pixels or points), independently of the transformation matrix of cr. If "layout", they are in the same units as the positions, and are scaled together with them. The value of res is always in output units.

max_render_timeint (optional, default: -1)

If nonnegative, this function will return an iterator that will perform part of the drawing at each step, so that each iteration takes at most max_render_time milliseconds.

vertex_*VertexPropertyMap or arbitrary types (optional, default: None)

Parameters following the pattern vertex_<prop-name> specify the vertex property with name <prop-name>, as an alternative to the vprops parameter.

edge_*EdgePropertyMap or arbitrary types (optional, default: None)

Parameters following the pattern edge_<prop-name> specify the edge property with name <prop-name>, as an alternative to the eprops parameter.

Returns:
iterator

If max_render_time is nonnegative, this will be an iterator that will perform part of the drawing at each step, so that each iteration takes at most max_render_time milliseconds.

See also

graph_draw

Draw a graph to a file or an interactive window

draw_hierarchy

Draw a nested block model hierarchy