Skip to content

Update axes_grid1 for recent API changes #5759

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 29, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions examples/axes_grid/simple_axisline4.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
r"$\pi$", r"$\frac{3}{2}\pi$", r"$2\pi$"])

ax2.axis["right"].major_ticklabels.set_visible(False)
ax2.axis["top"].major_ticklabels.set_visible(True)

plt.draw()
plt.show()
2 changes: 1 addition & 1 deletion lib/mpl_toolkits/axes_grid1/anchored_artists.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def __init__(self, transform, size, label, loc,

self.size_bar = AuxTransformBox(transform)
self.size_bar.add_artist(Rectangle((0, 0), size, size_vertical,
fill=True, facecolor=color,
fill=False, facecolor=color,
edgecolor=color))

# if fontproperties is None, but `prop` is not, assume that
Expand Down
4 changes: 2 additions & 2 deletions lib/mpl_toolkits/axes_grid1/inset_locator.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ def __init__(self, bbox1, bbox2, loc1, loc2=None, **kwargs):
raise ValueError("transform should not be set")

kwargs["transform"] = IdentityTransform()
Patch.__init__(self, **kwargs)
Patch.__init__(self, fill=False, **kwargs)
self.bbox1 = bbox1
self.bbox2 = bbox2
self.loc1 = loc1
Expand Down Expand Up @@ -582,7 +582,7 @@ def mark_inset(parent_axes, inset_axes, loc1, loc2, **kwargs):
"""
rect = TransformedBbox(inset_axes.viewLim, parent_axes.transData)

pp = BboxPatch(rect, **kwargs)
pp = BboxPatch(rect, fill=False, **kwargs)
parent_axes.add_patch(pp)

p1 = BboxConnector(inset_axes.bbox, rect, loc1=loc1, **kwargs)
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
51 changes: 51 additions & 0 deletions lib/mpl_toolkits/tests/test_axes_grid1.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

from mpl_toolkits.axes_grid1 import make_axes_locatable
from mpl_toolkits.axes_grid1 import AxesGrid
from mpl_toolkits.axes_grid1.inset_locator import zoomed_inset_axes, mark_inset
from mpl_toolkits.axes_grid1.anchored_artists import AnchoredSizeBar

from matplotlib.colors import LogNorm

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


@image_comparison(
baseline_images=['inset_locator'], style='default', extensions=['png'],
remove_text=True)
def test_inset_locator():
def get_demo_image():
from matplotlib.cbook import get_sample_data
import numpy as np
f = get_sample_data("axes_grid/bivariate_normal.npy", asfileobj=False)
z = np.load(f)
# z is a numpy array of 15x15
return z, (-3, 4, -4, 3)

fig, ax = plt.subplots(figsize=[5, 4])

# prepare the demo image
Z, extent = get_demo_image()
Z2 = np.zeros([150, 150], dtype="d")
ny, nx = Z.shape
Z2[30:30 + ny, 30:30 + nx] = Z

# extent = [-3, 4, -4, 3]
ax.imshow(Z2, extent=extent, interpolation="nearest",
origin="lower")

axins = zoomed_inset_axes(ax, 6, loc=1) # zoom = 6
axins.imshow(Z2, extent=extent, interpolation="nearest",
origin="lower")

# sub region of the original image
x1, x2, y1, y2 = -1.5, -0.9, -2.5, -1.9
axins.set_xlim(x1, x2)
axins.set_ylim(y1, y2)

plt.xticks(visible=False)
plt.yticks(visible=False)

# draw a bbox of the region of the inset axes in the parent axes and
# connecting lines between the bbox and the inset axes area
mark_inset(ax, axins, loc1=2, loc2=4, fc="none", ec="0.5")

asb = AnchoredSizeBar(ax.transData,
0.5,
'0.5',
loc=8,
pad=0.1, borderpad=0.5, sep=5,
frameon=False)
ax.add_artist(asb)


if __name__ == '__main__':
import nose
nose.runmodule(argv=['-s', '--with-doctest'], exit=False)