python-igraph API reference

List of all classes, functions and methods in python-igraph

package documentation

Drawing and plotting routines for igraph.

Plotting is dependent on the pycairo or cairocffi libraries that provide Python bindings to the popular Cairo library. This means that if you don't have pycairo or cairocffi installed, you won't be able to use the plotting capabilities. However, you can still use Graph.write_svg to save the graph to an SVG file and view it from Mozilla Firefox (free) or edit it in Inkscape (free), Skencil (formerly known as Sketch, also free) or Adobe Illustrator.

Whenever the documentation refers to the pycairo library, you can safely replace it with cairocffi as the two are API-compatible.

Module baseclasses Abstract base classes for the drawing routines.
Module colors Color handling functions.
Module coord Coordinate systems and related plotting routines
Module edge Drawers for various edge styles in graph plots.
Module graph Drawing routines to draw graphs.
Module metamagic Auxiliary classes for the default graph drawer in igraph.
Module shapes Shape drawing classes for igraph
Module text Drawers for labels on plots.
Module utils Utility classes for drawing routines.
Module vertex Drawing routines to draw the vertices of graphs.

From __init__.py:

Class Plot Class representing an arbitrary plot
Function plot Plots the given object to the given target.
Variable cairo Undocumented
cairo =

Undocumented

def plot(obj, target=None, bbox=(0, 0, 600, 600), *args, **kwds):

Plots the given object to the given target.

Positional and keyword arguments not explicitly mentioned here will be passed down to the __plot__ method of the object being plotted. Since you are most likely interested in the keyword arguments available for graph plots, see Graph.__plot__ as well.

Parameters
objthe object to be plotted
target

the target where the object should be plotted. It can be one of the following types:

  • matplotib.axes.Axes -- a matplotlib/pyplot axes in which the graph will be plotted. Drawing is delegated to the chosen matplotlib backend, and you can use interactive backends and matplotlib functions to save to file as well.
  • string -- a file with the given name will be created and an appropriate Cairo surface will be attached to it. The supported image formats are: PNG, PDF, SVG and PostScript.
  • cairo.Surface -- the given Cairo surface will be used. This can refer to a PNG image, an arbitrary window, an SVG file, anything that Cairo can handle.
  • None -- a temporary file will be created and the object will be plotted there. igraph will attempt to open an image viewer and show the temporary file. This feature is deprecated from igraph version 0.9.1 and will be removed in 0.10.0.
bboxthe bounding box of the plot. It must be a tuple with either two or four integers, or a BoundingBox object. If this is a tuple with two integers, it is interpreted as the width and height of the plot (in pixels for PNG images and on-screen plots, or in points for PDF, SVG and PostScript plots, where 72 pt = 1 inch = 2.54 cm). If this is a tuple with four integers, the first two denotes the X and Y coordinates of a corner and the latter two denoting the X and Y coordinates of the opposite corner.
*argsUndocumented
**kwdsUndocumented
opacitythe opacity of the object being plotted. It can be used to overlap several plots of the same graph if you use the same layout for them -- for instance, you might plot a graph with opacity 0.5 and then plot its spanning tree over it with opacity 0.1. To achieve this, you'll need to modify the Plot object returned with Plot.add.
palettethe palette primarily used on the plot if the added objects do not specify a private palette. Must be either an igraph.drawing.colors.Palette object or a string referring to a valid key of igraph.drawing.colors.palettes (see module igraph.drawing.colors) or None. In the latter case, the default palette given by the configuration key plotting.palette is used.
marginthe top, right, bottom, left margins as a 4-tuple. If it has less than 4 elements or is a single float, the elements will be re-used until the length is at least 4. The default margin is 20 on each side.
inlinewhether to try and show the plot object inline in the current IPython notebook. Passing None here or omitting this keyword argument will look up the preferred behaviour from the shell.ipython.inlining.Plot configuration key. Note that this keyword argument has an effect only if igraph is run inside IPython and target is None.
Returns
an appropriate Plot object.
See Also
Graph.__plot__