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

Method _add_input

lib/matplotlib/sankey.py:226–276  ·  view source on GitHub ↗

Add an input to a path and return its tip and label locations.

(self, path, angle, flow, length)

Source from the content-addressed store, hash-verified

224 np.tile(center, (ARC_VERTICES.shape[0], 1))))
225
226 def _add_input(self, path, angle, flow, length):
227 """
228 Add an input to a path and return its tip and label locations.
229 """
230 if angle is None:
231 return [0, 0], [0, 0]
232 else:
233 x, y = path[-1][1] # Use the last point as a reference.
234 dipdepth = (flow / 2) * self.pitch
235 if angle == RIGHT:
236 x -= length
237 dip = [x + dipdepth, y + flow / 2.0]
238 path.extend([(Path.LINETO, [x, y]),
239 (Path.LINETO, dip),
240 (Path.LINETO, [x, y + flow]),
241 (Path.LINETO, [x + self.gap, y + flow])])
242 label_location = [dip[0] - self.offset, dip[1]]
243 else: # Vertical
244 x -= self.gap
245 if angle == UP:
246 sign = 1
247 else:
248 sign = -1
249
250 dip = [x - flow / 2, y - sign * (length - dipdepth)]
251 if angle == DOWN:
252 quadrant = 2
253 else:
254 quadrant = 1
255
256 # Inner arc isn't needed if inner radius is zero
257 if self.radius:
258 path.extend(self._arc(quadrant=quadrant,
259 cw=angle == UP,
260 radius=self.radius,
261 center=(x + self.radius,
262 y - sign * self.radius)))
263 else:
264 path.append((Path.LINETO, [x, y]))
265 path.extend([(Path.LINETO, [x, y - sign * length]),
266 (Path.LINETO, dip),
267 (Path.LINETO, [x - flow, y - sign * length])])
268 path.extend(self._arc(quadrant=quadrant,
269 cw=angle == DOWN,
270 radius=flow + self.radius,
271 center=(x + self.radius,
272 y - sign * self.radius)))
273 path.append((Path.LINETO, [x - flow, y + sign * flow]))
274 label_location = [dip[0], dip[1] - sign * self.offset]
275
276 return dip, label_location
277
278 def _add_output(self, path, angle, flow, length):
279 """

Callers 1

addMethod · 0.95

Calls 1

_arcMethod · 0.95

Tested by

no test coverage detected