Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8599919

Browse files
committed
Cleanup axes_divider docstrings, and detail calculations.
HBoxDivider.new_locator doesn't have ny, ny1 parameters. The HBoxDivider.locate and VBoxDivider.locate docstrings are just copy-pasted from the parent one. Clarify some non-trivial calculations.
1 parent 766db51 commit 8599919

File tree

1 file changed

+8
-38
lines changed

1 file changed

+8
-38
lines changed

lib/mpl_toolkits/axes_grid1/axes_divider.py

Lines changed: 8 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -587,7 +587,6 @@ class HBoxDivider(SubplotDivider):
587587
def _determine_karray(equivalent_sizes, appended_sizes,
588588
max_equivalent_size,
589589
total_appended_size):
590-
591590
n = len(equivalent_sizes)
592591
eq_rs, eq_as = np.asarray(equivalent_sizes).T
593592
ap_rs, ap_as = np.asarray(appended_sizes).T
@@ -598,12 +597,14 @@ def _determine_karray(equivalent_sizes, appended_sizes,
598597
A[-1, :-1] = ap_rs
599598
B[:n] = -eq_as
600599
B[-1] = total_appended_size - sum(ap_as)
601-
602-
karray_H = np.linalg.solve(A, B) # A @ K = B
600+
# A @ K = B: This solves for {k_0, ..., k_{N-1}, H} so that
601+
# eq_r_i * k_i + eq_a_i = H for all i: all axes have the same height
602+
# sum(ap_r_i * k_i + ap_a_i) = total_appended_size: fixed total width
603+
# (foo_r_i * k_i + foo_a_i will end up being the size of foo.)
604+
karray_H = np.linalg.solve(A, B)
603605
karray = karray_H[:-1]
604606
H = karray_H[-1]
605-
606-
if H > max_equivalent_size:
607+
if H > max_equivalent_size: # Additionally, upper-bound the height.
607608
karray = (max_equivalent_size - eq_as) / eq_rs
608609
return karray
609610

@@ -625,8 +626,6 @@ def new_locator(self, nx, nx1=None):
625626
cell. When *nx1* is None, a single *nx*-th column is
626627
specified. Otherwise location of columns spanning between *nx*
627628
to *nx1* (but excluding *nx1*-th column) is specified.
628-
ny, ny1 : int
629-
Same as *nx* and *nx1*, but for row positions.
630629
"""
631630
return AxesLocator(self, nx, 0, nx1, None)
632631

@@ -655,21 +654,7 @@ def _locate(self, x, y, w, h,
655654
return x0, y0, ox, hh
656655

657656
def locate(self, nx, ny, nx1=None, ny1=None, axes=None, renderer=None):
658-
"""
659-
Parameters
660-
----------
661-
axes_divider : AxesDivider
662-
nx, nx1 : int
663-
Integers specifying the column-position of the
664-
cell. When *nx1* is None, a single *nx*-th column is
665-
specified. Otherwise location of columns spanning between *nx*
666-
to *nx1* (but excluding *nx1*-th column) is specified.
667-
ny, ny1 : int
668-
Same as *nx* and *nx1*, but for row positions.
669-
axes
670-
renderer
671-
"""
672-
657+
# docstring inherited
673658
figW, figH = self._fig.get_size_inches()
674659
x, y, w, h = self.get_position_runtime(axes, renderer)
675660

@@ -707,27 +692,12 @@ def new_locator(self, ny, ny1=None):
707692
return AxesLocator(self, 0, ny, None, ny1)
708693

709694
def locate(self, nx, ny, nx1=None, ny1=None, axes=None, renderer=None):
710-
"""
711-
Parameters
712-
----------
713-
axes_divider : AxesDivider
714-
nx, nx1 : int
715-
Integers specifying the column-position of the
716-
cell. When *nx1* is None, a single *nx*-th column is
717-
specified. Otherwise location of columns spanning between *nx*
718-
to *nx1* (but excluding *nx1*-th column) is specified.
719-
ny, ny1 : int
720-
Same as *nx* and *nx1*, but for row positions.
721-
axes
722-
renderer
723-
"""
724-
695+
# docstring inherited
725696
figW, figH = self._fig.get_size_inches()
726697
x, y, w, h = self.get_position_runtime(axes, renderer)
727698

728699
x_equivalent_sizes = self.get_horizontal_sizes(renderer)
729700
y_appended_sizes = self.get_vertical_sizes(renderer)
730-
731701
y0, x0, oy, ww = self._locate(y, x, h, w,
732702
x_equivalent_sizes, y_appended_sizes,
733703
figH, figW)

0 commit comments

Comments
 (0)