|
1 | 1 | """ |
2 | 2 | .. _demo-colorbar-with-inset-locator: |
3 | 3 |
|
4 | | -=========================================================== |
5 | | -Control the position and size of a colorbar with Inset Axes |
6 | | -=========================================================== |
| 4 | +========================================================================= |
| 5 | +Control the position and size of a colorbar with inset_locator.inset_axes |
| 6 | +========================================================================= |
7 | 7 |
|
8 | 8 | This example shows how to control the position, height, and width of colorbars |
9 | | -using `~mpl_toolkits.axes_grid1.inset_locator.inset_axes`. |
| 9 | +using `.inset_locator.inset_axes`. |
10 | 10 |
|
11 | | -Inset Axes placement is controlled as for legends: either by providing a *loc* |
12 | | -option ("upper right", "best", ...), or by providing a locator with respect to |
13 | | -the parent bbox. Parameters such as *bbox_to_anchor* and *borderpad* likewise |
14 | | -work in the same way, and are also demonstrated here. |
| 11 | +`.inset_locator.inset_axes` placement is controlled as for legends: either |
| 12 | +by providing a *loc* option ("upper right", "best", ...), or by providing a |
| 13 | +locator with respect to the parent bbox. Parameters such as *bbox_to_anchor* |
| 14 | +and *borderpad* likewise work in the same way, and are also demonstrated here. |
15 | 15 |
|
16 | 16 | Users should consider using `.Axes.inset_axes` instead (see |
17 | 17 | :ref:`colorbar_placement`). |
|
21 | 21 |
|
22 | 22 | import matplotlib.pyplot as plt |
23 | 23 |
|
24 | | -from mpl_toolkits.axes_grid1.inset_locator import inset_axes |
| 24 | +from mpl_toolkits.axes_grid1 import inset_locator |
25 | 25 |
|
26 | 26 | fig, (ax1, ax2) = plt.subplots(1, 2, figsize=[6, 3]) |
27 | 27 |
|
28 | 28 | im1 = ax1.imshow([[1, 2], [2, 3]]) |
29 | | -axins1 = inset_axes( |
| 29 | +axins1 = inset_locator.inset_axes( |
30 | 30 | ax1, |
31 | 31 | width="50%", # width: 50% of parent_bbox width |
32 | 32 | height="5%", # height: 5% |
|
36 | 36 | fig.colorbar(im1, cax=axins1, orientation="horizontal", ticks=[1, 2, 3]) |
37 | 37 |
|
38 | 38 | im = ax2.imshow([[1, 2], [2, 3]]) |
39 | | -axins = inset_axes( |
| 39 | +axins = inset_locator.inset_axes( |
40 | 40 | ax2, |
41 | 41 | width="5%", # width: 5% of parent_bbox width |
42 | 42 | height="50%", # height: 50% |
|
0 commit comments