Regardless of the kinds of inputs supported by the graph API, the mark itself should have the following characteristics:

  • Doesn't care about directionality in the internal representation - it renders every edge it receives, regardless of direction, parallel edges, etc.
  • Vertices support all of the styles / attributes of a scatterplot - color, size, marker, etc.
  • Edges support color, opacity, stroke width attributes.
  • Edges support start / end markers for directionality.
  • Supports multiple layout algorithms.
  • Are graphs added to Cartesian axes? Or are they a type of axis, like table axes?

In [1]:
import numpy
import toyplot

In [2]:
import igraph
numpy.random.seed(1234)
graph = igraph.Graph.GRG(20, 0.5)
graph.summary()
coords = numpy.array(graph.layout("auto").coords)
x = coords[:, 0]
y = coords[:, 1]
source = [edge.source for edge in graph.es]
target = [edge.target for edge in graph.es]

In [3]:
colormap = toyplot.color.LinearMap(toyplot.color.Palette(["white", "yellow", "orange", "red"]))

ecolor = numpy.random.uniform(size=len(graph.es))
vcolor = numpy.random.uniform(size=len(graph.vs))

canvas = toyplot.Canvas(style={"background-color":"#bbb"})
axes = canvas.axes(show=False)
axes.graph(x, y, source, target, edge_color=(ecolor, colormap), edge_opacity=1, vertex_color=(vcolor, colormap), size=100, mstyle={"stroke":"black"})


Out[3]:
<toyplot.mark.Graph at 0x10d8b8c50>
[u'title']

In [ ]: