GraphArtist#

class graph_tool.draw.GraphArtist(g, pos, ax, vprops=None, eprops=None, raster=False, **kwargs)[git][source]#

Bases: Artist

matplotlib.artist.Artist specialization that draws Graph instances in a matplotlib figure.

Warning

Vector drawing is available only on cairo-based backends. For other backends, rasterization will be used.

Parameters:
gGraph

Graph to be drawn.

posVertexPropertyMap

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

axmatplotlib.axes.Axes

A matplotlib.axes.Axes instance where the graph will be drawn.

vpropsdict (optional, default: None)

Dictionary with the vertex properties.

epropsdict (optional, default: None)

Dictionary with the edge properties.

rasterbool (optional, default: False)

If True, the graph will be rasterized even if a cairo-based backend is being used.

**kwargsdict (optional, default: None)

Remaining options to pass to cairo_draw().

Methods

draw(renderer)

Draw the Artist (and its children) using the given renderer.

draw_to_cairo(ctx, transform[, mag])

Draw to a cairo context.

fit_view([scale, margin, yflip, ...])

Set axis limits to fit the graph, optionally scaling it via the scale parameter, and adding a relative margin given by margin.

get_extents()

Return a matplotlib.transforms.Bbox with the node position limits.

set_raster([raster])

If raster == True, then the graph will be rasterized even if a cairo-based backend is being used.

Attributes

draw(renderer)[git][source]#

Draw the Artist (and its children) using the given renderer.

This has no effect if the artist is not visible (.Artist.get_visible returns False).

Parameters:
renderer~matplotlib.backend_bases.RendererBase subclass.

Notes

This method is overridden in the Artist subclasses.

draw_to_cairo(ctx, transform, mag=1)[git][source]#

Draw to a cairo context.

fit_view(scale=1, margin=0.1, yflip=False, keep_aspect=True, set_axis_aspect=False)[git][source]#

Set axis limits to fit the graph, optionally scaling it via the scale parameter, and adding a relative margin given by margin. If yflip is True, the y axis is flipped upside down. If keep_aspect is True, the aspect ratio is preserved via the data limits. Otherwise, if set_axis_aspect is True, the aspect of the axis will be changed to match the data aspect.

get_extents()[git][source]#

Return a matplotlib.transforms.Bbox with the node position limits.

set_raster(raster=True)[git][source]#

If raster == True, then the graph will be rasterized even if a cairo-based backend is being used.

zorder = 0#