Skip to content

Commit

Permalink
Fix sankey_demo_links.py pep8 and py3 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
cgohlke committed Jun 30, 2012
1 parent 3e7ff0d commit 829e253
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions examples/api/sankey_demo_links.py
@@ -1,31 +1,35 @@
"""Demonstrate/test the Sankey class by producing a long chain of connections. """Demonstrate/test the Sankey class by producing a long chain of connections.
""" """
import numpy as np
import matplotlib.pyplot as plt


from matplotlib.sankey import Sankey
from itertools import cycle from itertools import cycle


import matplotlib.pyplot as plt
from matplotlib.sankey import Sankey

links_per_side = 6 links_per_side = 6


def side(sankey, n=1): def side(sankey, n=1):
"""Generate a side chain. """Generate a side chain."""
"""
prior = len(sankey.diagrams) prior = len(sankey.diagrams)
colors = cycle(['orange', 'b', 'g', 'r', 'c', 'm', 'y']) colors = cycle(['orange', 'b', 'g', 'r', 'c', 'm', 'y'])
for i in range(0, 2*n, 2): for i in range(0, 2*n, 2):
sankey.add(flows=[1, -1], orientations=[-1, -1], sankey.add(flows=[1, -1], orientations=[-1, -1],
patchlabel=str(prior+i), facecolor=colors.next(), patchlabel=str(prior+i), facecolor=next(colors),
prior=prior+i-1, connect=(1, 0), alpha=0.5) prior=prior+i-1, connect=(1, 0), alpha=0.5)
sankey.add(flows=[1, -1], orientations=[1, 1], sankey.add(flows=[1, -1], orientations=[1, 1],
patchlabel=str(prior+i+1), facecolor=colors.next(), patchlabel=str(prior+i+1), facecolor=next(colors),
prior=prior+i, connect=(1, 0), alpha=0.5) prior=prior+i, connect=(1, 0), alpha=0.5)


def corner(sankey): def corner(sankey):
"""Generate a corner link. """Generate a corner link."""
"""
prior = len(sankey.diagrams) prior = len(sankey.diagrams)
sankey.add(flows=[1, -1], orientations=[0, 1], sankey.add(flows=[1, -1], orientations=[0, 1],
patchlabel=str(prior), facecolor='k', patchlabel=str(prior), facecolor='k',
prior=prior-1, connect=(1, 0), alpha=0.5) prior=prior-1, connect=(1, 0), alpha=0.5)


fig = plt.figure() fig = plt.figure()
ax = fig.add_subplot(1, 1, 1, xticks=[], yticks=[], ax = fig.add_subplot(1, 1, 1, xticks=[], yticks=[],
title="Why would you want to do this?\n(But you could.)") title="Why would you want to do this?\n(But you could.)")
Expand Down

0 comments on commit 829e253

Please sign in to comment.