Sankey diagram. Sankey diagrams are a specific type of flow diagram, in which the width of the arrows is shown proportionally to the flow quantity. They are typically used to visualize energy or material or cost transfers between processes. `Wikipedia (6/1/2011)
| 28 | |
| 29 | |
| 30 | class Sankey: |
| 31 | """ |
| 32 | Sankey diagram. |
| 33 | |
| 34 | Sankey diagrams are a specific type of flow diagram, in which |
| 35 | the width of the arrows is shown proportionally to the flow |
| 36 | quantity. They are typically used to visualize energy or |
| 37 | material or cost transfers between processes. |
| 38 | `Wikipedia (6/1/2011) <https://en.wikipedia.org/wiki/Sankey_diagram>`_ |
| 39 | |
| 40 | """ |
| 41 | |
| 42 | def __init__(self, ax=None, scale=1.0, unit='', format='%G', gap=0.25, |
| 43 | radius=0.1, shoulder=0.03, offset=0.15, head_angle=100, |
| 44 | margin=0.4, tolerance=1e-6, **kwargs): |
| 45 | """ |
| 46 | Create a new Sankey instance. |
| 47 | |
| 48 | The optional arguments listed below are applied to all subdiagrams so |
| 49 | that there is consistent alignment and formatting. |
| 50 | |
| 51 | In order to draw a complex Sankey diagram, create an instance of |
| 52 | `Sankey` by calling it without any kwargs:: |
| 53 | |
| 54 | sankey = Sankey() |
| 55 | |
| 56 | Then add simple Sankey sub-diagrams:: |
| 57 | |
| 58 | sankey.add() # 1 |
| 59 | sankey.add() # 2 |
| 60 | #... |
| 61 | sankey.add() # n |
| 62 | |
| 63 | Finally, create the full diagram:: |
| 64 | |
| 65 | sankey.finish() |
| 66 | |
| 67 | Or, instead, simply daisy-chain those calls:: |
| 68 | |
| 69 | Sankey().add().add... .add().finish() |
| 70 | |
| 71 | Other Parameters |
| 72 | ---------------- |
| 73 | ax : `~matplotlib.axes.Axes` |
| 74 | Axes onto which the data should be plotted. If *ax* isn't |
| 75 | provided, new Axes will be created. |
| 76 | scale : float |
| 77 | Scaling factor for the flows. *scale* sizes the width of the paths |
| 78 | in order to maintain proper layout. The same scale is applied to |
| 79 | all subdiagrams. The value should be chosen such that the product |
| 80 | of the scale and the sum of the inputs is approximately 1.0 (and |
| 81 | the product of the scale and the sum of the outputs is |
| 82 | approximately -1.0). |
| 83 | unit : str |
| 84 | The physical unit associated with the flow quantities. If *unit* |
| 85 | is None, then none of the quantities are labeled. |
| 86 | format : str or callable |
| 87 | A Python number formatting string or callable used to label the |
no outgoing calls
searching dependent graphs…