GraphArtist#
- class graph_tool.draw.GraphArtist(g, pos, ax, vprops=None, eprops=None, raster=False, **kwargs)[git][source]#
Bases:
Artistmatplotlib.artist.Artistspecialization that drawsGraphinstances in amatplotlibfigure.Warning
Vector drawing is available only on cairo-based backends. For other backends, rasterization will be used.
- Parameters:
- g
Graph Graph to be drawn.
- pos
VertexPropertyMap Vector-valued vertex property map containing the x and y coordinates of the vertices.
- ax
matplotlib.axes.Axes A
matplotlib.axes.Axesinstance 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().
- g
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
scaleparameter, and adding a relative margin given bymargin.Return a
matplotlib.transforms.Bboxwith 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.
- 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
scaleparameter, and adding a relative margin given bymargin. Ifyflip is True, the y axis is flipped upside down. Ifkeep_aspect is True, the aspect ratio is preserved via the data limits. Otherwise, ifset_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.Bboxwith 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#