8000 Merge pull request #16746 from anntzer/cbwad · matplotlib/matplotlib@e283ff6 · GitHub
[go: up one dir, main page]

Skip to content

Commit e283ff6

Browse files
authored
Merge pull request #16746 from anntzer/cbwad
Reword colorbar-with-axes-divider example.
2 parents eba349a + 1ddd224 commit e283ff6

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed
Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
"""
2-
===============================
3-
Demo Colorbar with Axes Divider
4-
===============================
2+
============================
3+
Colorbar with `.AxesDivider`
4+
============================
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.
6+
The `.axes_divider.make_axes_locatable` function takes an existing axes, adds
7+
it to a new `.AxesDivider` and returns the `.AxesDivider`. The `.append_axes`
8+
method of the `.AxesDivider` can then be used to create a new axes on a given
9+
side ("top", "right", "bottom", or "left") of the original axes. This example
10+
uses `.append_axes` to add colorbars next to axes.
1211
"""
1312

1413
import matplotlib.pyplot as plt
@@ -19,17 +18,17 @@
1918

2019
im1 = ax1.imshow([[1, 2], [3, 4]])
2120
ax1_divider = make_axes_locatable(ax1)
22-
# add an axes to the right of the main axes.
21+
# Add an axes to the right of the main axes.
2322
cax1 = ax1_divider.append_axes("right", size="7%", pad="2%")
2423
cb1 = fig.colorbar(im1, cax=cax1)
2524

2625
im2 = ax2.imshow([[1, 2], [3, 4]])
2726
ax2_divider = make_axes_locatable(ax2)
28-
# add an axes above the main axes.
27+
# Add an axes above the main axes.
2928
cax2 = ax2_divider.append_axes("top", size="7%", pad="2%")
3029
cb2 = fig.colorbar(im2, cax=cax2, orientation="horizontal")
31-
# change tick position to top. Tick position defaults to bottom and overlaps
32-
# the image.
30+
# Change tick position to top (with the default tick position "bottom", ticks
31+
# overlap the image).
3332
cax2.xaxis.set_ticks_position("top")
3433

3534
plt.show()

0 commit comments

Comments
 (0)
0