Stream Graphs with Python
Upcoming SlideShare
Loading in...5
×
 

Stream Graphs with Python

on

  • 6,622 views

 

Statistics

Views

Total Views
6,622
Views on SlideShare
3,761
Embed Views
2,861

Actions

Likes
2
Downloads
15
Comments
0

5 Embeds 2,861

http://mechanicalintegrator.com 2706
http://tumblr.zest.id.lv 125
http://www.slideshare.net 21
http://translate.googleusercontent.com 6
http://bitly.com 3

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Stream Graphs with Python Presentation Transcript

  • 1. Making Stream Graphs with Python Nathan Bergey April 29, 2010 Nathan Bergey Making Stream Graphs with Python
  • 2. Starting Point I said “Hey, I can do that” Then, later, I did that Nathan Bergey Making Stream Graphs with Python
  • 3. Python and Paper Working with Python was easy. http://leebyron.com/else/streamgraph/ Nathan Bergey Making Stream Graphs with Python
  • 4. Stacked Graphs Nathan Bergey Making Stream Graphs with Python
  • 5. Move it down Start at with g0 being some number other than 0. Nathan Bergey Making Stream Graphs with Python
  • 6. Symmetry Nathan Bergey Making Stream Graphs with Python
  • 7. A Simple Algorithm n 1 g0 = − fi 2 i=1 Nathan Bergey Making Stream Graphs with Python
  • 8. A More Complex Algorithm n 1 g0 = − (n − i + 1)fi n+1 i=1 Nathan Bergey Making Stream Graphs with Python
  • 9. Comparison Nathan Bergey Making Stream Graphs with Python
  • 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
  • 15. A Single Shape Nathan Bergey Making Stream Graphs with Python
  • 16. Labeling Not actually possible? Packing algorithms Make some random boxes Keep the largest one Nathan Bergey Making Stream Graphs with Python
  • 17. SVG Using SVGFig http://code.google.com/p/svgfig/ Could be better Custom interpolation? Nathan Bergey Making Stream Graphs with Python
  • 18. Resources Me: @natronics pystreamgraph: http://github.com/natronics/pystreamgraph Nathan Bergey Making Stream Graphs with Python