Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Fix gridspec demo #952

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
Jun 17, 2012
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
8 changes: 4 additions & 4 deletions doc/users/plotting/examples/demo_gridspec06.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def product(*args, **kwds):
def squiggle_xy(a, b, c, d, i=np.arange(0.0, 2*np.pi, 0.05)):
return np.sin(i*a)*np.cos(i*b), np.sin(i*c)*np.cos(i*d)

f = plt.figure(figsize=(8, 8))
fig = plt.figure(figsize=(8, 8))

# gridspec inside gridspec
outer_grid = gridspec.GridSpec(4, 4, wspace=0.0, hspace=0.0)
Expand All @@ -28,13 +28,13 @@ def squiggle_xy(a, b, c, d, i=np.arange(0.0, 2*np.pi, 0.05)):
subplot_spec=outer_grid[i], wspace=0.0, hspace=0.0)
a, b = int(i/4)+1,i%4+1
for j, (c, d) in enumerate(product(range(1, 4), repeat=2)):
ax = plt.Subplot(f, inner_grid[j])
ax = plt.Subplot(fig, inner_grid[j])
ax.plot(*squiggle_xy(a, b, c, d))
ax.set_xticks([])
ax.set_yticks([])
f.add_subplot(ax)
fig.add_subplot(ax)

all_axes = f.get_axes()
all_axes = fig.get_axes()

#show only the outside spines
for ax in all_axes:
Expand Down
4 changes: 3 additions & 1 deletion lib/matplotlib/figure.py
Original file line number Diff line number Diff line change
Expand Up @@ -791,7 +791,9 @@ def add_subplot(self, *args, **kwargs):

a = args[0]
assert(a.get_figure() is self)
key = self._make_key(*args[1:], **kwargs)
# make a key for the subplot (which includes the axes object id
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I introduced this in 37e3851. I hadn't appreciated that the axes (or rather, the axes' object id) was intentionally part of the key.

# in the hash)
key = self._make_key(*args, **kwargs)
else:
projection_class, kwargs, key = \
process_projection_requirements(self, *args, **kwargs)
Expand Down