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

Class VPacker

lib/matplotlib/offsetbox.py:435–472  ·  view source on GitHub ↗

VPacker packs its children vertically, 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

433
434
435class VPacker(PackerBase):
436 """
437 VPacker packs its children vertically, automatically adjusting their
438 relative positions at draw time.
439
440 .. code-block:: none
441
442 +---------+
443 | Child 1 |
444 | Child 2 |
445 | Child 3 |
446 +---------+
447 """
448
449 def _get_bbox_and_child_offsets(self, renderer):
450 # docstring inherited
451 dpicor = renderer.points_to_pixels(1.)
452 pad = self.pad * dpicor
453 sep = self.sep * dpicor
454
455 if self.width is not None:
456 for c in self.get_visible_children():
457 if isinstance(c, PackerBase) and c.mode == "expand":
458 c.set_width(self.width)
459
460 bboxes = [c.get_bbox(renderer) for c in self.get_visible_children()]
461 (x0, x1), xoffsets = _get_aligned_offsets(
462 [bbox.intervalx for bbox in bboxes], self.width, self.align)
463 height, yoffsets = _get_packed_offsets(
464 [bbox.height for bbox in bboxes], self.height, sep, self.mode)
465
466 yoffsets = height - (yoffsets + [bbox.y1 for bbox in bboxes])
467 ydescent = yoffsets[0]
468 yoffsets = yoffsets - ydescent
469
470 return (
471 Bbox.from_bounds(x0, -ydescent, x1 - x0, height).padded(pad),
472 [*zip(xoffsets, yoffsets)])
473
474
475class HPacker(PackerBase):

Callers 4

__init__Method · 0.90
_init_legend_boxMethod · 0.90
test_packersFunction · 0.90
draw_sizebarFunction · 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…