|
| 1 | +AxesDivider |
| 2 | +=========== |
| 3 | + |
| 4 | +The axes_divider module provide helper classes to adjust the axes |
| <
67E6
td data-grid-cell-id="diff-8e1634c53166036461bdfc0c3e19cefdae7a6dc7e4ff4dac1782585d4c5c938b-empty-5-1" data-selected="false" role="gridcell" style="background-color:var(--diffBlob-additionNum-bgColor, var(--diffBlob-addition-bgColor-num));text-align:center" tabindex="-1" valign="top" class="focusable-grid-cell diff-line-number position-relative left-side">5
+positions of set of images in the drawing time. |
| 6 | + |
| 7 | +* *Size* This provides a classese of units that the size of each axes |
| 8 | + will be determined. For example, you can specify a fixed size |
| 9 | + |
| 10 | +* *Divider* this is the class that is used calculates the axes |
| 11 | + position. It divides the given renctangular area into several |
| 12 | + areas. You intialize the divider by setting the horizontal and |
| 13 | + vertical list of sizes that the division will be based on. You then |
| 14 | + use the new_locator method, whose return value is a callable object |
| 15 | + that can be used to set the axes_locator of the axes. |
| 16 | + |
| 17 | + |
| 18 | +You first initialize the divider by specifying its grids, i.e., horiz and vert. |
| 19 | + |
| 20 | +for example,:: |
| 21 | + |
| 22 | + rect = [0.2, 0.2, 0.6, 0.6] |
| 23 | + horiz=[h0, h1, h2, h3] |
| 24 | + vert=[v0, v1, v2] |
| 25 | + divider = Divider(fig, rect, horiz, vert) |
| 26 | + |
| 27 | +where, rect is a bounds of the box that will be divided and h0,..h3, |
| 28 | +v0,..v2 need to be an callable object that returns a tuple of two |
| 29 | +floats. The first float is the relative size, and the second float is |
| 30 | +the absolute size. Use of the subclasses contained in the Size class |
| 31 | +is recommanded. Lets' consider a following grid. |
| 32 | + |
| 33 | ++-----+-----+-----+-----+ |
| 34 | +| v0 | | | | |
| 35 | ++-----+-----+-----+-----+ |
| 36 | +| v1 | | | | |
| 37 | ++-----+-----+-----+-----+ |
| 38 | +|h0,v2| h1 | h2 | h3 | |
| 39 | ++-----+-----+-----+-----+ |
| 40 | + |
| 41 | + |
| 42 | +* h0 => 2, 0 |
| 43 | +* h1 => 0, 2 |
| 44 | +* h2 => 0, 3 |
| 45 | + |
| 46 | +The height of the bottom row is always 2 (axes_divider internally |
| 47 | +assumes that the unit is inch). The first and the second rows with |
| 48 | +height ration of 2:3. For example, if the total height of the grid 6, |
| 49 | +the the first and second row will each occupy 2/(2+3) and 3/(2+3) of |
| 50 | +(6-1) inches. The widths of columns (horiz) will be similarly |
| 51 | +determined. When aspect ratio is set, the total height (or width) will |
| 52 | +be adjusted accordingly. |
| 53 | + |
| 54 | + |
| 55 | +The Size class is a container class that contains several sub-class |
| 56 | +that can be used to set the horiz and vert. For example, for the |
| 57 | +vertical configuration above will be:: |
| 58 | + |
| 59 | + from Size import Fixed, Scaled |
| 60 | + vert = [Fixed(2), Scaled(2), Scaled(3)] |
| 61 | + |
| 62 | +After you set up the divider object, you |
| 63 | +Then you create a locator instance which will be given to the axes.:: |
| 64 | + |
| 65 | + locator = divider.new_locator(nx=0, ny=1) |
| 66 | + ax.set_axes_locator(locator) |
| 67 | + |
| 68 | +The return value of the new_locator method is a instance of the |
| 69 | +AxesLocator class. It is a callable object that will return the |
| 70 | +location and size of the cell at the first column and the second row. |
| 71 | +You may create a locator that spans over multiple cells.:: |
| 72 | + |
| 73 | + locator = divider.new_locator(nx=0, nx=2, ny=1) |
| 74 | + |
| 75 | +The above locator, when called, will return the position and size of |
| 76 | +the cells spanning the first and second column and the first row. You |
| 77 | +may consider it as [0:2, 1]. |
| 78 | + |
| 79 | +See the example, |
| 80 | + |
| 81 | +.. plot:: mpl_toolkits/axes_grid/figures/simple_axes_divider2.py |
| 82 | + :include-source: |
| 83 | + |
| 84 | +You can adjust the size of the each axes accroding to their x or y |
| 85 | +data limits (AxesX and AxesY), similar to the axes aspect parameter. |
| 86 | + |
| 87 | +.. plot:: mpl_toolkits/axes_grid/figures/simple_axes_divider3.py |
| 88 | + :include-source: |
| 89 | + |
0 commit comments