|
15 | 15 | # Example 1 -- Mostly defaults |
16 | 16 | # This demonstrates how to create a simple diagram by implicitly calling the |
17 | 17 | # Sankey.add() method and by appending finish() to the call to the class. |
| 18 | + |
18 | 19 | Sankey(flows=[0.25, 0.15, 0.60, -0.20, -0.15, -0.05, -0.50, -0.10], |
19 | 20 | labels=['', '', '', 'First', 'Second', 'Third', 'Fourth', 'Fifth'], |
20 | 21 | orientations=[-1, 1, 0, 1, 1, 1, 0, -1]).finish() |
21 | 22 | plt.title("The default settings produce a diagram like this.") |
| 23 | + |
22 | 24 | ############################################################################### |
23 | 25 | # Notice: |
24 | 26 | # 1. Axes weren't provided when Sankey() was instantiated, so they were |
|
39 | 41 | # 7. Formatting the numbers in the path labels and the associated unit |
40 | 42 | # 8. Changing the appearance of the patch and the labels after the figure is |
41 | 43 | # created |
| 44 | + |
42 | 45 | fig = plt.figure() |
43 | 46 | ax = fig.add_subplot(1, 1, 1, xticks=[], yticks=[], |
44 | 47 | title="Flow Diagram of a Widget") |
|
54 | 57 | diagrams = sankey.finish() |
55 | 58 | diagrams[0].texts[-1].set_color('r') |
56 | 59 | diagrams[0].text.set_fontweight('bold') |
| 60 | + |
57 | 61 | ############################################################################### |
58 | 62 | # Notice: |
59 | 63 | # 1. Since the sum of the flows is nonzero, the width of the trunk isn't |
|
68 | 72 | # 1. Connecting two systems |
69 | 73 | # 2. Turning off the labels of the quantities |
70 | 74 | # 3. Adding a legend |
| 75 | + |
71 | 76 | fig = plt.figure() |
72 | 77 | ax = fig.add_subplot(1, 1, 1, xticks=[], yticks=[], title="Two Systems") |
73 | 78 | flows = [0.25, 0.15, 0.60, -0.10, -0.05, -0.25, -0.15, -0.10, -0.35] |
|
79 | 84 | diagrams = sankey.finish() |
80 | 85 | diagrams[-1].patch.set_hatch('/') |
81 | 86 | plt.legend(loc='best') |
| 87 | + |
82 | 88 | ############################################################################### |
83 | 89 | # Notice that only one connection is specified, but the systems form a |
84 | 90 | # circuit since: (1) the lengths of the paths are justified and (2) the |
|
0 commit comments