Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 829e253

Browse files
committed
Fix sankey_demo_links.py pep8 and py3 compatibility
1 parent 3e7ff0d commit 829e253

1 file changed

Lines changed: 13 additions & 9 deletions

File tree

examples/api/sankey_demo_links.py

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,35 @@
11
"""Demonstrate/test the Sankey class by producing a long chain of connections.
22
"""
3-
import numpy as np
4-
import matplotlib.pyplot as plt
53

6-
from matplotlib.sankey import Sankey
74
from itertools import cycle
85

6+
import matplotlib.pyplot as plt
7+
from matplotlib.sankey import Sankey
8+
99
links_per_side = 6
10+
11+
1012
def side(sankey, n=1):
11-
"""Generate a side chain.
12-
"""
13+
"""Generate a side chain."""
1314
prior = len(sankey.diagrams)
1415
colors = cycle(['orange', 'b', 'g', 'r', 'c', 'm', 'y'])
1516
for i in range(0, 2*n, 2):
1617
sankey.add(flows=[1, -1], orientations=[-1, -1],
17-
patchlabel=str(prior+i), facecolor=colors.next(),
18+
patchlabel=str(prior+i), facecolor=next(colors),
1819
prior=prior+i-1, connect=(1, 0), alpha=0.5)
1920
sankey.add(flows=[1, -1], orientations=[1, 1],
20-
patchlabel=str(prior+i+1), facecolor=colors.next(),
21+
patchlabel=str(prior+i+1), facecolor=next(colors),
2122
prior=prior+i, connect=(1, 0), alpha=0.5)
23+
24+
2225
def corner(sankey):
23-
"""Generate a corner link.
24-
"""
26+
"""Generate a corner link."""
2527
prior = len(sankey.diagrams)
2628
sankey.add(flows=[1, -1], orientations=[0, 1],
2729
patchlabel=str(prior), facecolor='k',
2830
prior=prior-1, connect=(1, 0), alpha=0.5)
31+
32+
2933
fig = plt.figure()
3034
ax = fig.add_subplot(1, 1, 1, xticks=[], yticks=[],
3135
title="Why would you want to do this?\n(But you could.)")

0 commit comments

Comments
 (0)