20
20
from matplotlib .gridspec import GridSpec
21
21
22
22
23
- def generate_imshow_demo_grid (auto_limits , extents ):
23
+ def generate_imshow_demo_grid (extents , auto_limits ):
24
24
N = len (extents )
25
25
fig = plt .figure (tight_layout = True )
26
26
fig .set_size_inches (6 , N * (11.25 ) / 5 )
@@ -29,8 +29,8 @@ def generate_imshow_demo_grid(auto_limits, extents):
29
29
columns = {'label' : [fig .add_subplot (gs [j , 0 ]) for j in range (N )],
30
30
'upper' : [fig .add_subplot (gs [j , 1 :3 ]) for j in range (N )],
31
31
'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
34
34
35
35
for origin in ['upper' , 'lower' ]:
36
36
for ax , extent in zip (columns [origin ], extents ):
@@ -69,7 +69,6 @@ def generate_imshow_demo_grid(auto_limits, extents):
69
69
ha = 'center' , va = 'top' , ** ann_kwargs )
70
70
ax .annotate (lower_string , xy = (.5 , 0 ), xytext = (0 , 1 ),
71
71
ha = 'center' , va = 'bottom' , ** ann_kwargs )
72
-
73
72
ax .annotate (port_string , xy = (0 , .5 ), xytext = (1 , 0 ),
74
73
ha = 'left' , va = 'center' , rotation = 90 ,
75
74
** ann_kwargs )
@@ -125,12 +124,8 @@ def generate_imshow_demo_grid(auto_limits, extents):
125
124
# ``(left, top)`` moves along the ``[:, 0]`` axis of the array to
126
125
# lower index rows and moving towards ``(right, bottom)`` moves you
127
126
# 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
- #
132
127
133
- generate_imshow_demo_grid (True , extents [:1 ])
128
+ generate_imshow_demo_grid (extents [:1 ], auto_limits = True )
134
129
135
130
###############################################################################
136
131
#
@@ -151,18 +146,15 @@ def generate_imshow_demo_grid(auto_limits, extents):
151
146
# which defaults to ``'upper'`` to match the matrix indexing
152
147
# conventions in math and computer graphics image indexing
153
148
# conventions.
154
-
155
- generate_imshow_demo_grid (True , extents [1 :])
156
-
157
- ###############################################################################
158
149
#
159
150
# If the axes is set to autoscale, then view limits of the axes are set
160
151
# to match the *extent* which ensures that the coordinate set by
161
152
# ``(left, bottom)`` is at the bottom left of the axes! However, this
162
153
# may invert the axis so they do not increase in the 'natural' direction.
163
154
#
164
155
165
- generate_imshow_demo_grid (False , extents )
156
+ generate_imshow_demo_grid (extents [1 :], auto_limits = True )
157
+
166
158
167
159
###############################################################################
168
160
#
@@ -177,3 +169,5 @@ def generate_imshow_demo_grid(auto_limits, extents):
177
169
# - The image may be inverted along either direction.
178
170
# - The 'left-right' and 'top-bottom' sense of the image is uncoupled from
179
171
# the orientation on the screen.
172
+
173
+ generate_imshow_demo_grid (extents , auto_limits = False )
0 commit comments