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

Class HPacker

lib/matplotlib/offsetbox.py:475–506  ·  view source on GitHub ↗

HPacker packs its children horizontally, automatically adjusting their relative positions at draw time. .. code-block:: none +-------------------------------+ | Child 1 Child 2 Child 3 | +-------------------------------+

Source from the content-addressed store, hash-verified

473
474
475class HPacker(PackerBase):
476 """
477 HPacker packs its children horizontally, automatically adjusting their
478 relative positions at draw time.
479
480 .. code-block:: none
481
482 +-------------------------------+
483 | Child 1 Child 2 Child 3 |
484 +-------------------------------+
485 """
486
487 def _get_bbox_and_child_offsets(self, renderer):
488 # docstring inherited
489 dpicor = renderer.points_to_pixels(1.)
490 pad = self.pad * dpicor
491 sep = self.sep * dpicor
492
493 bboxes = [c.get_bbox(renderer) for c in self.get_visible_children()]
494 if not bboxes:
495 return Bbox.from_bounds(0, 0, 0, 0).padded(pad), []
496
497 (y0, y1), yoffsets = _get_aligned_offsets(
498 [bbox.intervaly for bbox in bboxes], self.height, self.align)
499 width, xoffsets = _get_packed_offsets(
500 [bbox.width for bbox in bboxes], self.width, sep, self.mode)
501
502 x0 = bboxes[0].x0
503 xoffsets -= ([bbox.x0 for bbox in bboxes] - x0)
504
505 return (Bbox.from_bounds(x0, y0, width, y1 - y0).padded(pad),
506 [*zip(xoffsets, yoffsets)])
507
508
509class PaddedBox(OffsetBox):

Callers 3

_init_legend_boxMethod · 0.90
test_packersFunction · 0.90
annotations.pyFile · 0.90

Calls

no outgoing calls

Tested by 1

test_packersFunction · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…