Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1"""
2@file
3@brief Helpers for presentations.
4"""
7def show_images(name1, name2=None, title1=None, title2=None, figsize=(12, 4)):
8 """
9 Uses :epkg:`matplotlib` to show images.
11 @param name1 name of the first image
12 @param name2 name of the second image
13 @param title1 title for the first image
14 @param title2 title for the second image
15 @param figsize figure size
16 @return ax
17 """
18 import matplotlib.pyplot as plt
19 import matplotlib.image as mpimg
21 img1 = mpimg.imread(name1)
22 if name2 is None:
23 _, ax = plt.subplots(1, 1, figsize=figsize)
24 img2 = None
25 ax.imshow(img1)
26 ax.get_xaxis().set_visible(False)
27 ax.get_yaxis().set_visible(False)
28 if title1 is not None:
29 ax.set_title(title1)
30 else:
31 _, ax = plt.subplots(1, 2, figsize=figsize)
32 img2 = mpimg.imread(name2)
33 ax[0].imshow(img1)
34 ax[0].get_xaxis().set_visible(False)
35 ax[0].get_yaxis().set_visible(False)
36 ax[1].imshow(img2)
37 ax[1].get_xaxis().set_visible(False)
38 ax[1].get_yaxis().set_visible(False)
39 if title1 is not None:
40 ax[0].set_title(title1)
41 if title2 is not None:
42 ax[1].set_title(title2)
43 return ax