From 1db0c21b7022b877f2e850d3dde251ece79c76f2 Mon Sep 17 00:00:00 2001 From: Nelle Varoquaux Date: Thu, 24 Jan 2019 17:25:18 +1100 Subject: [PATCH 1/3] DOC Better description of inset locator and colorbar --- .../demo_colorbar_with_inset_locator.py | 23 ++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/examples/axes_grid1/demo_colorbar_with_inset_locator.py b/examples/axes_grid1/demo_colorbar_with_inset_locator.py index 79d2001c1ea6..02c386dece8e 100644 --- a/examples/axes_grid1/demo_colorbar_with_inset_locator.py +++ b/examples/axes_grid1/demo_colorbar_with_inset_locator.py @@ -1,7 +1,14 @@ """ -================================ -Demo Colorbar With Inset Locator -================================ +======================================================= +Controling the position of colorbars With Inset Locator +======================================================= + +This example shows how to control the position, height, and width of +colorbars using `~mpl_toolkits.axes_grid1.inset_axes`. + +Controlling the placement of the inset axes is done similarly as that of the +legend: either by providing a location option ("upper right", "best", ...), or +by providing a locator with respect to the parent bbox. """ import matplotlib.pyplot as plt @@ -11,16 +18,16 @@ fig, (ax1, ax2) = plt.subplots(1, 2, figsize=[6, 3]) axins1 = inset_axes(ax1, - width="50%", # width = 10% of parent_bbox width - height="5%", # height : 50% + width="50%", # width = 50% of parent_bbox width + height="5%", # height : 5% loc='upper right') im1 = ax1.imshow([[1, 2], [2, 3]]) -plt.colorbar(im1, cax=axins1, orientation="horizontal", ticks=[1, 2, 3]) +fig.colorbar(im1, cax=axins1, orientation="horizontal", ticks=[1, 2, 3]) axins1.xaxis.set_ticks_position("bottom") axins = inset_axes(ax2, - width="5%", # width = 10% of parent_bbox width + width="5%", # width = 5% of parent_bbox width height="50%", # height : 50% loc='lower left', bbox_to_anchor=(1.05, 0., 1, 1), @@ -33,6 +40,6 @@ # the bbox_to_anchor coordinate. im = ax2.imshow([[1, 2], [2, 3]]) -plt.colorbar(im, cax=axins, ticks=[1, 2, 3]) +fig.colorbar(im, cax=axins, ticks=[1, 2, 3]) plt.show() From ebac45174fbca2e612216ca4da7f39a9070cfaa9 Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: Thu, 24 Jan 2019 18:39:42 +1100 Subject: [PATCH 2/3] Update examples/axes_grid1/demo_colorbar_with_inset_locator.py Co-Authored-By: NelleV --- examples/axes_grid1/demo_colorbar_with_inset_locator.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/axes_grid1/demo_colorbar_with_inset_locator.py b/examples/axes_grid1/demo_colorbar_with_inset_locator.py index 02c386dece8e..893d6fa7cb00 100644 --- a/examples/axes_grid1/demo_colorbar_with_inset_locator.py +++ b/examples/axes_grid1/demo_colorbar_with_inset_locator.py @@ -1,6 +1,6 @@ """ ======================================================= -Controling the position of colorbars With Inset Locator +Controlling the position of colorbars with Inset Locator ======================================================= This example shows how to control the position, height, and width of From eecd184092560ffbd162200d49d6aaa7e6f67357 Mon Sep 17 00:00:00 2001 From: Nelle Varoquaux Date: Thu, 24 Jan 2019 18:41:25 +1100 Subject: [PATCH 3/3] DOC Nitpick on title --- examples/axes_grid1/demo_colorbar_with_inset_locator.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/axes_grid1/demo_colorbar_with_inset_locator.py b/examples/axes_grid1/demo_colorbar_with_inset_locator.py index 893d6fa7cb00..0133da3f22b4 100644 --- a/examples/axes_grid1/demo_colorbar_with_inset_locator.py +++ b/examples/axes_grid1/demo_colorbar_with_inset_locator.py @@ -1,7 +1,7 @@ """ -======================================================= -Controlling the position of colorbars with Inset Locator -======================================================= +============================================================== +Controlling the position and size of colorbars with Inset Axes +============================================================== This example shows how to control the position, height, and width of colorbars using `~mpl_toolkits.axes_grid1.inset_axes`.