@@ -841,124 +841,4 @@ def finish(self):
841841 self .ax .set_aspect ('equal' , adjustable = 'datalim' )
842842 return self .diagrams
843843
844- def __init__ (self , ax = None , scale = 1.0 , unit = '' , format = '%G ' , gap = 0.25 ,
845- radius = 0.1 , shoulder = 0.03 , offset = 0.15 , head_angle = 100 ,
846- margin = 0.4 , tolerance = 1e-6 , ** kwargs ):
847- """
848- Create a new Sankey instance.
849-
850- Optional keyword arguments:
851-
852- =============== ===================================================
853- Field Description
854- =============== ===================================================
855- *ax* axes onto which the data should be plotted
856- If *ax* is not provided, new axes will be created.
857- *scale* scaling factor for the flows
858- *scale* sizes the width of the paths in order to
859- maintain proper layout. The same scale is applied
860- to all subdiagrams. The value should be chosen
861- such that the product of the scale and the sum of
862- the inputs is approximately 1.0 (and the product of
863- the scale and the sum of the outputs is
864- approximately -1.0).
865- *unit* string representing the physical unit associated
866- with the flow quantities
867- If *unit* is *None*, then none of the quantities
868- are labeled.
869- *format* a Python number formatting string to be used in
870- labeling the flow as a quantity (i.e., a number
871- times a unit, where the unit is given)
872- *gap* space between paths that break in/break away
873- to/from the top or bottom
874- *radius* inner radius of the vertical paths
875- *shoulder* size of the shoulders of output arrows
876- *offset* text offset (from the dip or tip of the arrow)
877- *head_angle* angle of the arrow heads (and negative of the angle
878- of the tails) [deg]
879- *margin* minimum space between Sankey outlines and the edge
880- of the plot area
881- *tolerance* acceptable maximum of the magnitude of the sum of
882- flows
883- The magnitude of the sum of connected flows cannot
884- be greater than *tolerance*.
885- =============== ===================================================
886-
887- The optional arguments listed above are applied to all subdiagrams so
888- that there is consistent alignment and formatting.
889-
890- If :class:`Sankey` is instantiated with any keyword arguments other
891- than those explicitly listed above (``**kwargs``), they will be passed
892- to :meth:`add`, which will create the first subdiagram.
893-
894- In order to draw a complex Sankey diagram, create an instance of
895- :class:`Sankey` by calling it without any kwargs::
896-
897- sankey = Sankey()
898-
899- Then add simple Sankey sub-diagrams::
900-
901- sankey.add() # 1
902- sankey.add() # 2
903- #...
904- sankey.add() # n
905-
906- Finally, create the full diagram::
907844
908- sankey.finish()
909-
910- Or, instead, simply daisy-chain those calls::
911-
912- Sankey().add().add... .add().finish()
913-
914- .. seealso::
915-
916- :meth:`add`
917- :meth:`finish`
918-
919-
920- **Examples:**
921-
922- .. plot:: mpl_examples/api/sankey_demo_basics.py
923- """
924- # Check the arguments.
925- assert gap >= 0 , (
926- "The gap is negative.\n This isn't allowed because it "
927- "would cause the paths to overlap." )
928- assert radius <= gap , (
929- "The inner radius is greater than the path spacing.\n "
930- "This isn't allowed because it would cause the paths to overlap." )
931- assert head_angle >= 0 , (
932- "The angle is negative.\n This isn't allowed "
933- "because it would cause inputs to look like "
934- "outputs and vice versa." )
935- assert tolerance >= 0 , (
936- "The tolerance is negative.\n It must be a magnitude." )
937-
938- # Create axes if necessary.
939- if ax is None :
940- import matplotlib .pyplot as plt
941- fig = plt .figure ()
942- ax = fig .add_subplot (1 , 1 , 1 , xticks = [], yticks = [])
943-
944- self .diagrams = []
945-
946- # Store the inputs.
947- self .ax = ax
948- self .unit = unit
949- self .format = format
950- self .scale = scale
951- self .gap = gap
952- self .radius = radius
953- self .shoulder = shoulder
954- self .offset = offset
955- self .margin = margin
956- self .pitch = np .tan (np .pi * (1 - head_angle / 180.0 ) / 2.0 )
957- self .tolerance = tolerance
958-
959- # Initialize the vertices of tight box around the diagram(s).
960- self .extent = np .array ((np .inf , - np .inf , np .inf , - np .inf ))
961-
962- # If there are any kwargs, create the first subdiagram.
963- if len (kwargs ):
964- self .add (** kwargs )
0 commit comments