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 07999b1

Browse filesBrowse files
committed
Merge pull request #5759 from mdboom/issue5757
Update axes_grid1 for recent API changes
2 parents dcf50b3 + 0ffa48e commit 07999b1
Copy full SHA for 07999b1

File tree

Expand file treeCollapse file tree

5 files changed

+55
-3
lines changed
Filter options
Expand file treeCollapse file tree

5 files changed

+55
-3
lines changed

‎examples/axes_grid/simple_axisline4.py

Copy file name to clipboardExpand all lines: examples/axes_grid/simple_axisline4.py
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
r"$\pi$", r"$\frac{3}{2}\pi$", r"$2\pi$"])
1414

1515
ax2.axis["right"].major_ticklabels.set_visible(False)
16+
ax2.axis["top"].major_ticklabels.set_visible(True)
1617

1718
plt.draw()
1819
plt.show()

‎lib/mpl_toolkits/axes_grid1/anchored_artists.py

Copy file name to clipboardExpand all lines: lib/mpl_toolkits/axes_grid1/anchored_artists.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ def __init__(self, transform, size, label, loc,
125125

126126
self.size_bar = AuxTransformBox(transform)
127127
self.size_bar.add_artist(Rectangle((0, 0), size, size_vertical,
128-
fill=True, facecolor=color,
128+
fill=False, facecolor=color,
129129
edgecolor=color))
130130

131131
# if fontproperties is None, but `prop` is not, assume that

‎lib/mpl_toolkits/axes_grid1/inset_locator.py

Copy file name to clipboardExpand all lines: lib/mpl_toolkits/axes_grid1/inset_locator.py
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ def __init__(self, bbox1, bbox2, loc1, loc2=None, **kwargs):
312312
raise ValueError("transform should not be set")
313313

314314
kwargs["transform"] = IdentityTransform()
315-
Patch.__init__(self, **kwargs)
315+
Patch.__init__(self, fill=False, **kwargs)
316316
self.bbox1 = bbox1
317317
self.bbox2 = bbox2
318318
self.loc1 = loc1
@@ -582,7 +582,7 @@ def mark_inset(parent_axes, inset_axes, loc1, loc2, **kwargs):
582582
"""
583583
rect = TransformedBbox(inset_axes.viewLim, parent_axes.transData)
584584

585-
pp = BboxPatch(rect, **kwargs)
585+
pp = BboxPatch(rect, fill=False, **kwargs)
586586
parent_axes.add_patch(pp)
587587

588588
p1 = BboxConnector(inset_axes.bbox, rect, loc1=loc1, **kwargs)
Loading

‎lib/mpl_toolkits/tests/test_axes_grid1.py

Copy file name to clipboardExpand all lines: lib/mpl_toolkits/tests/test_axes_grid1.py
+51Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
from mpl_toolkits.axes_grid1 import make_axes_locatable
1010
from mpl_toolkits.axes_grid1 import AxesGrid
11+
from mpl_toolkits.axes_grid1.inset_locator import zoomed_inset_axes, mark_inset
12+
from mpl_toolkits.axes_grid1.anchored_artists import AnchoredSizeBar
1113

1214
from matplotlib.colors import LogNorm
1315

@@ -72,6 +74,55 @@ def test_axesgrid_colorbar_log_smoketest():
7274
grid.cbar_axes[0].colorbar(im)
7375

7476

77+
@image_comparison(
78+
baseline_images=['inset_locator'], style='default', extensions=['png'],
79+
remove_text=True)
80+
def test_inset_locator():
81+
def get_demo_image():
82+
from matplotlib.cbook import get_sample_data
83+
import numpy as np
84+
f = get_sample_data("axes_grid/bivariate_normal.npy", asfileobj=False)
85+
z = np.load(f)
86+
# z is a numpy array of 15x15
87+
return z, (-3, 4, -4, 3)
88+
89+
fig, ax = plt.subplots(figsize=[5, 4])
90+
91+
# prepare the demo image
92+
Z, extent = get_demo_image()
93+
Z2 = np.zeros([150, 150], dtype="d")
94+
ny, nx = Z.shape
95+
Z2[30:30 + ny, 30:30 + nx] = Z
96+
97+
# extent = [-3, 4, -4, 3]
98+
ax.imshow(Z2, extent=extent, interpolation="nearest",
99+
origin="lower")
100+
101+
axins = zoomed_inset_axes(ax, 6, loc=1) # zoom = 6
102+
axins.imshow(Z2, extent=extent, interpolation="nearest",
103+
origin="lower")
104+
105+
# sub region of the original image
106+
x1, x2, y1, y2 = -1.5, -0.9, -2.5, -1.9
107+
axins.set_xlim(x1, x2)
108+
axins.set_ylim(y1, y2)
109+
110+
plt.xticks(visible=False)
111+
plt.yticks(visible=False)
112+
113+
# draw a bbox of the region of the inset axes in the parent axes and
114+
# connecting lines between the bbox and the inset axes area
115+
mark_inset(ax, axins, loc1=2, loc2=4, fc="none", ec="0.5")
116+
117+
asb = AnchoredSizeBar(ax.transData,
118+
0.5,
119+
'0.5',
120+
loc=8,
121+
pad=0.1, borderpad=0.5, sep=5,
122+
frameon=False)
123+
ax.add_artist(asb)
124+
125+
75126
if __name__ == '__main__':
76127
import nose
77128
nose.runmodule(argv=['-s', '--with-doctest'], exit=False)

0 commit comments

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