Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 38efc4d

Browse filesBrowse 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
Copy full SHA for 38efc4d

File tree

Expand file treeCollapse file tree

1 file changed

+10
-0
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+10
-0
lines changed

‎examples/axes_grid1/demo_colorbar_with_axes_divider.py

Copy file name to clipboardExpand all lines: examples/axes_grid1/demo_colorbar_with_axes_divider.py
+10Lines 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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.