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 464dde1

Browse filesBrowse files
committed
Cleanup demo_axes_hbox_divider.
- Small rewording. - Use the make_heights_equal function demo'ed in the example, rather than copy-pasting it. - For the central annotation, use a figure-level text() instead of an invisible axes.
1 parent 2f6a7a4 commit 464dde1
Copy full SHA for 464dde1

File tree

Expand file treeCollapse file tree

1 file changed

+11
-20
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+11
-20
lines changed
+11-20Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
"""
2-
======================
3-
Demo Axes Hbox Divider
4-
======================
2+
===================
3+
`.HBoxDivider` demo
4+
===================
55
6-
Hbox Divider to arrange subplots.
6+
Using an `.HboxDivider` to arrange subplots.
77
"""
88

99
import numpy as np
@@ -31,22 +31,13 @@ def make_heights_equal(fig, rect, ax1, ax2, pad):
3131
ax1.imshow(arr1)
3232
ax2.imshow(arr2)
3333

34-
pad = 0.5 # inches.
35-
divider = HBoxDivider(
36-
fig, 111, # Position of combined axes.
37-
horizontal=[Size.AxesX(ax1), Size.Fixed(pad), Size.AxesX(ax2)],
38-
vertical=[Size.AxesY(ax1), Size.Scaled(1), Size.AxesY(ax2)])
39-
ax1.set_axes_locator(divider.new_locator(0))
40-
ax2.set_axes_locator(divider.new_locator(2))
34+
make_heights_equal(fig, 111, ax1, ax2, pad=0.5)
4135

42-
# annotate
43-
ax3 = plt.axes([0.5, 0.5, 0.001, 0.001], frameon=False)
44-
ax3.xaxis.set_visible(False)
45-
ax3.yaxis.set_visible(False)
46-
ax3.annotate("Location of two axes are adjusted\n"
47-
"so that they have equal heights\n"
48-
"while maintaining their aspect ratios", (0.5, 0.5),
49-
xycoords="axes fraction", va="center", ha="center",
50-
bbox=dict(boxstyle="round, pad=1", fc="w"))
36+
fig.text(.5, .5,
37+
"Both axes' location are adjusted\n"
38+
"so that they have equal heights\n"
39+
"while maintaining their aspect ratios",
40+
va="center", ha="center",
41+
bbox=dict(boxstyle="round, pad=1", facecolor="w"))
5142

5243
plt.show()

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.