Skip to content

Commit e461640

Browse files
committed
DOC: tweak helper method kwargs and example data
1 parent 1124ec9 commit e461640

File tree

1 file changed

+8
-14
lines changed

1 file changed

+8
-14
lines changed

tutorials/intermediate/imshow_extent.py

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
from matplotlib.gridspec import GridSpec
2121

2222

23-
def generate_imshow_demo_grid(auto_limits, extents):
23+
def generate_imshow_demo_grid(extents, auto_limits):
2424
N = len(extents)
2525
fig = plt.figure(tight_layout=True)
2626
fig.set_size_inches(6, N * (11.25) / 5)
@@ -29,8 +29,8 @@ def generate_imshow_demo_grid(auto_limits, extents):
2929
columns = {'label': [fig.add_subplot(gs[j, 0]) for j in range(N)],
3030
'upper': [fig.add_subplot(gs[j, 1:3]) for j in range(N)],
3131
'lower': [fig.add_subplot(gs[j, 3:5]) for j in range(N)]}
32-
33-
d = np.arange(42).reshape(6, 7)
32+
x, y = np.ogrid[0:6, 0:7]
33+
d = x + y
3434

3535
for origin in ['upper', 'lower']:
3636
for ax, extent in zip(columns[origin], extents):
@@ -69,7 +69,6 @@ def generate_imshow_demo_grid(auto_limits, extents):
6969
ha='center', va='top', **ann_kwargs)
7070
ax.annotate(lower_string, xy=(.5, 0), xytext=(0, 1),
7171
ha='center', va='bottom', **ann_kwargs)
72-
7372
ax.annotate(port_string, xy=(0, .5), xytext=(1, 0),
7473
ha='left', va='center', rotation=90,
7574
**ann_kwargs)
@@ -125,12 +124,8 @@ def generate_imshow_demo_grid(auto_limits, extents):
125124
# ``(left, top)`` moves along the ``[:, 0]`` axis of the array to
126125
# lower index rows and moving towards ``(right, bottom)`` moves you
127126
# along the ``[-1, :]`` axis of the array to higher indexed columns
128-
#
129-
# To demonstrate this we will plot a linear ramp
130-
# ``np.arange(42).reshape(6, 7)`` with varying parameters.
131-
#
132127

133-
generate_imshow_demo_grid(True, extents[:1])
128+
generate_imshow_demo_grid(extents[:1], auto_limits=True)
134129

135130
###############################################################################
136131
#
@@ -151,18 +146,15 @@ def generate_imshow_demo_grid(auto_limits, extents):
151146
# which defaults to ``'upper'`` to match the matrix indexing
152147
# conventions in math and computer graphics image indexing
153148
# conventions.
154-
155-
generate_imshow_demo_grid(True, extents[1:])
156-
157-
###############################################################################
158149
#
159150
# If the axes is set to autoscale, then view limits of the axes are set
160151
# to match the *extent* which ensures that the coordinate set by
161152
# ``(left, bottom)`` is at the bottom left of the axes! However, this
162153
# may invert the axis so they do not increase in the 'natural' direction.
163154
#
164155

165-
generate_imshow_demo_grid(False, extents)
156+
generate_imshow_demo_grid(extents[1:], auto_limits=True)
157+
166158

167159
###############################################################################
168160
#
@@ -177,3 +169,5 @@ def generate_imshow_demo_grid(auto_limits, extents):
177169
# - The image may be inverted along either direction.
178170
# - The 'left-right' and 'top-bottom' sense of the image is uncoupled from
179171
# the orientation on the screen.
172+
173+
generate_imshow_demo_grid(extents, auto_limits=False)

0 commit comments

Comments
 (0)