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 5713554

Browse filesBrowse files
authored
Merge pull request #16774 from anntzer/hbd
Cleanup demo_axes_hbox_divider.
2 parents 54b4263 + de54b03 commit 5713554
Copy full SHA for 5713554

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.