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

Skip to content

Commit 38efc4d

Browse files
authored
Merge pull request #13157 from meeseeksmachine/auto-backport-of-pr-13152-on-v3.0.x
Backport PR #13152 on branch v3.0.x (DOC: Add explanatory comment for colorbar with axes divider example)
2 parents 672c029 + 0b6e0bd commit 38efc4d

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

examples/axes_grid1/demo_colorbar_with_axes_divider.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
33
Demo Colorbar with Axes Divider
44
===============================
55
6+
The make_axes_locatable function (part of the axes_divider module) takes an
7+
existing axes, creates a divider for it and returns an instance of the
8+
AxesLocator class. The append_axes method of this AxesLocator can then be used
9+
to create a new axes on a given side ("top", "right", "bottom", or "left") of
10+
the original axes. This example uses Axes Divider to add colorbars next to
11+
axes.
612
"""
713

814
import matplotlib.pyplot as plt
@@ -14,13 +20,17 @@
1420

1521
im1 = ax1.imshow([[1, 2], [3, 4]])
1622
ax1_divider = make_axes_locatable(ax1)
23+
# add an axes to the right of the main axes.
1724
cax1 = ax1_divider.append_axes("right", size="7%", pad="2%")
1825
cb1 = colorbar(im1, cax=cax1)
1926

2027
im2 = ax2.imshow([[1, 2], [3, 4]])
2128
ax2_divider = make_axes_locatable(ax2)
29+
# add an axes above the main axes.
2230
cax2 = ax2_divider.append_axes("top", size="7%", pad="2%")
2331
cb2 = colorbar(im2, cax=cax2, orientation="horizontal")
32+
# change tick position to top. Tick position defaults to bottom and overlaps
33+
# the image.
2434
cax2.xaxis.set_ticks_position("top")
2535

2636
plt.show()

0 commit comments

Comments
 (0)