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

Method _do_cell_alignment

lib/matplotlib/table.py:466–495  ·  view source on GitHub ↗

Calculate row heights and column widths; position cells accordingly.

(self)

Source from the content-addressed store, hash-verified

464 return Bbox.union(boxes)
465
466 def _do_cell_alignment(self):
467 """
468 Calculate row heights and column widths; position cells accordingly.
469 """
470 # Calculate row/column widths
471 widths = {}
472 heights = {}
473 for (row, col), cell in self._cells.items():
474 height = heights.setdefault(row, 0.0)
475 heights[row] = max(height, cell.get_height())
476 width = widths.setdefault(col, 0.0)
477 widths[col] = max(width, cell.get_width())
478
479 # work out left position for each column
480 xpos = 0
481 lefts = {}
482 for col in sorted(widths):
483 lefts[col] = xpos
484 xpos += widths[col]
485
486 ypos = 0
487 bottoms = {}
488 for row in sorted(heights, reverse=True):
489 bottoms[row] = ypos
490 ypos += heights[row]
491
492 # set cell positions
493 for (row, col), cell in self._cells.items():
494 cell.set_x(lefts[col])
495 cell.set_y(bottoms[row])
496
497 def auto_set_column_width(self, col):
498 """

Callers 1

_update_positionsMethod · 0.95

Calls 4

get_heightMethod · 0.45
get_widthMethod · 0.45
set_xMethod · 0.45
set_yMethod · 0.45

Tested by

no test coverage detected