MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / _add_output

Method _add_output

lib/matplotlib/sankey.py:278–330  ·  view source on GitHub ↗

Append an output to a path and return its tip and label locations. .. note:: *flow* is negative for an output.

(self, path, angle, flow, length)

Source from the content-addressed store, hash-verified

276 return dip, label_location
277
278 def _add_output(self, path, angle, flow, length):
279 """
280 Append an output to a path and return its tip and label locations.
281
282 .. note:: *flow* is negative for an output.
283 """
284 if angle is None:
285 return [0, 0], [0, 0]
286 else:
287 x, y = path[-1][1] # Use the last point as a reference.
288 tipheight = (self.shoulder - flow / 2) * self.pitch
289 if angle == RIGHT:
290 x += length
291 tip = [x + tipheight, y + flow / 2.0]
292 path.extend([(Path.LINETO, [x, y]),
293 (Path.LINETO, [x, y + self.shoulder]),
294 (Path.LINETO, tip),
295 (Path.LINETO, [x, y - self.shoulder + flow]),
296 (Path.LINETO, [x, y + flow]),
297 (Path.LINETO, [x - self.gap, y + flow])])
298 label_location = [tip[0] + self.offset, tip[1]]
299 else: # Vertical
300 x += self.gap
301 if angle == UP:
302 sign, quadrant = 1, 3
303 else:
304 sign, quadrant = -1, 0
305
306 tip = [x - flow / 2.0, y + sign * (length + tipheight)]
307 # Inner arc isn't needed if inner radius is zero
308 if self.radius:
309 path.extend(self._arc(quadrant=quadrant,
310 cw=angle == UP,
311 radius=self.radius,
312 center=(x - self.radius,
313 y + sign * self.radius)))
314 else:
315 path.append((Path.LINETO, [x, y]))
316 path.extend([(Path.LINETO, [x, y + sign * length]),
317 (Path.LINETO, [x - self.shoulder,
318 y + sign * length]),
319 (Path.LINETO, tip),
320 (Path.LINETO, [x + self.shoulder - flow,
321 y + sign * length]),
322 (Path.LINETO, [x - flow, y + sign * length])])
323 path.extend(self._arc(quadrant=quadrant,
324 cw=angle == DOWN,
325 radius=self.radius - flow,
326 center=(x - self.radius,
327 y + sign * self.radius)))
328 path.append((Path.LINETO, [x - flow, y + sign * flow]))
329 label_location = [tip[0], tip[1] + sign * self.offset]
330 return tip, label_location
331
332 def _revert(self, path, first_action=Path.LINETO):
333 """

Callers 1

addMethod · 0.95

Calls 1

_arcMethod · 0.95

Tested by

no test coverage detected