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

Skip to content

Commit 622448d

Browse files
authored
Merge pull request #17001 from anntzer/imshow_extent
Cleanup imshow_extent tutorial.
2 parents afa8d28 + ac10acb commit 622448d

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

tutorials/intermediate/imshow_extent.py

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -148,21 +148,15 @@ def generate_imshow_demo_grid(extents, xlim=None, ylim=None):
148148
for ax, extent in zip(columns[origin], extents):
149149
plot_imshow_with_labels(ax, data, extent, origin, xlim, ylim)
150150

151+
columns['label'][0].set_title('extent=')
151152
for ax, extent in zip(columns['label'], extents):
152-
text_kwargs = {'ha': 'right',
153-
'va': 'center',
154-
'xycoords': 'axes fraction',
155-
'xy': (1, .5)}
156153
if extent is None:
157-
ax.annotate('None', **text_kwargs)
158-
ax.set_title('extent=')
154+
text = 'None'
159155
else:
160156
left, right, bottom, top = extent
161-
text = ('left: {left:0.1f}\nright: {right:0.1f}\n' +
162-
'bottom: {bottom:0.1f}\ntop: {top:0.1f}\n').format(
163-
left=left, right=right, bottom=bottom, top=top)
164-
165-
ax.annotate(text, **text_kwargs)
157+
text = (f'left: {left:0.1f}\nright: {right:0.1f}\n'
158+
f'bottom: {bottom:0.1f}\ntop: {top:0.1f}\n')
159+
ax.text(1., .5, text, transform=ax.transAxes, ha='right', va='center')
166160
ax.axis('off')
167161
return columns
168162

@@ -263,3 +257,5 @@ def generate_imshow_demo_grid(extents, xlim=None, ylim=None):
263257

264258
generate_imshow_demo_grid(extents=[None] + extents,
265259
xlim=(-2, 8), ylim=(-1, 6))
260+
261+
plt.show()

0 commit comments

Comments
 (0)