diff --git a/galleries/examples/axes_grid1/demo_colorbar_of_inset_axes.py b/galleries/examples/axes_grid1/demo_colorbar_of_inset_axes.py deleted file mode 100644 index 341e11ff52b5..000000000000 --- a/galleries/examples/axes_grid1/demo_colorbar_of_inset_axes.py +++ /dev/null @@ -1,33 +0,0 @@ -""" -=============================== -Adding a colorbar to inset axes -=============================== -""" - -import matplotlib.pyplot as plt - -from matplotlib import cbook -from mpl_toolkits.axes_grid1.inset_locator import inset_axes, zoomed_inset_axes - -fig, ax = plt.subplots(figsize=[5, 4]) -ax.set(aspect=1, xlim=(-15, 15), ylim=(-20, 5)) - -Z = cbook.get_sample_data("axes_grid/bivariate_normal.npy") -extent = (-3, 4, -4, 3) - -axins = zoomed_inset_axes(ax, zoom=2, loc='upper left') -axins.set(xticks=[], yticks=[]) -im = axins.imshow(Z, extent=extent, origin="lower") - -# colorbar -cax = inset_axes(axins, - width="5%", # width = 10% of parent_bbox width - height="100%", # height : 50% - loc='lower left', - bbox_to_anchor=(1.05, 0., 1, 1), - bbox_transform=axins.transAxes, - borderpad=0, - ) -fig.colorbar(im, cax=cax) - -plt.show() diff --git a/galleries/examples/axes_grid1/demo_colorbar_with_axes_divider.py b/galleries/examples/axes_grid1/demo_colorbar_with_axes_divider.py index 9e4611c65bb7..0c0771013c9f 100644 --- a/galleries/examples/axes_grid1/demo_colorbar_with_axes_divider.py +++ b/galleries/examples/axes_grid1/demo_colorbar_with_axes_divider.py @@ -14,6 +14,8 @@ Users should consider simply passing the main axes to the *ax* keyword argument of `~.Figure.colorbar` instead of creating a locatable axes manually like this. See :ref:`colorbar_placement`. + +.. redirect-from:: /gallery/axes_grid1/simple_colorbar """ import matplotlib.pyplot as plt diff --git a/galleries/examples/axes_grid1/demo_colorbar_with_inset_locator.py b/galleries/examples/axes_grid1/demo_colorbar_with_inset_locator.py index 8ec7d0e7271b..e450485150d7 100644 --- a/galleries/examples/axes_grid1/demo_colorbar_with_inset_locator.py +++ b/galleries/examples/axes_grid1/demo_colorbar_with_inset_locator.py @@ -16,6 +16,7 @@ Users should consider using `.Axes.inset_axes` instead (see :ref:`colorbar_placement`). +.. redirect-from:: /gallery/axes_grid1/demo_colorbar_of_inset_axes """ import matplotlib.pyplot as plt diff --git a/galleries/examples/axes_grid1/simple_colorbar.py b/galleries/examples/axes_grid1/simple_colorbar.py deleted file mode 100644 index 5617cb0b6b4b..000000000000 --- a/galleries/examples/axes_grid1/simple_colorbar.py +++ /dev/null @@ -1,22 +0,0 @@ -""" -=============== -Simple Colorbar -=============== - -""" -import matplotlib.pyplot as plt -import numpy as np - -from mpl_toolkits.axes_grid1 import make_axes_locatable - -ax = plt.subplot() -im = ax.imshow(np.arange(100).reshape((10, 10))) - -# create an Axes on the right side of ax. The width of cax will be 5% -# of ax and the padding between cax and ax will be fixed at 0.05 inch. -divider = make_axes_locatable(ax) -cax = divider.append_axes("right", size="5%", pad=0.05) - -plt.colorbar(im, cax=cax) - -plt.show() diff --git a/galleries/users_explain/toolkits/axes_grid.rst b/galleries/users_explain/toolkits/axes_grid.rst index ba37c4cf7d78..6f7be49ed4c1 100644 --- a/galleries/users_explain/toolkits/axes_grid.rst +++ b/galleries/users_explain/toolkits/axes_grid.rst @@ -81,8 +81,8 @@ side ("left", "right", "top", "bottom") of the original axes. colorbar whose height (or width) is in sync with the main axes -------------------------------------------------------------- -.. figure:: /gallery/axes_grid1/images/sphx_glr_simple_colorbar_001.png - :target: /gallery/axes_grid1/simple_colorbar.html +.. figure:: /gallery/axes_grid1/images/sphx_glr_demo_colorbar_with_axes_divider_001.png + :target: /gallery/axes_grid1/demo_colorbar_with_axes_divider.html :align: center scatter_hist.py with AxesDivider