10. pystreamgraph
http://github.com/natronics/pystreamgraph
Takes a list of a list of data points.
You provide Colors, Labels, etc.
Draws it, but with some options
Nathan Bergey
Making Stream Graphs with Python
11. Preprocess
Calculate the sum of the y values
for i in range(0, n_points):
y_sum = 0
for layer in range(0, n_layers):
y_sum += data[layer][i][1]
y_extent.append(y_sum)
Nathan Bergey
Making Stream Graphs with Python
12. Step 1
Calculate g0
g_0 = []
for i in range(n_points):
g_0.append(- y_extent[i] / 2.0)
Nathan Bergey
Making Stream Graphs with Python
13. Draw it
for layer in range(n_layers):
points = []
point_range = range(n_points)
for i in point_range:
x = data[layer][i][0]
y = data[layer][i][1]
y_stacked = g_0[i] + y
for l in range(layer):
y_stacked += self.data[l][i][1]
points.append((x, y_stacked))
Nathan Bergey
Making Stream Graphs with Python
14. Draw it
point_range.reverse()
for i in point_range:
x = self.data[layer][i][0]
y_stacked = g_0[i]
for l in range(layer):
y_stacked += self.data[l][i][1]
points.append((x,y_stacked))
Nathan Bergey
Making Stream Graphs with Python