Skip to content

Commit c643f20

Browse files
author
Mike Davidson
committed
Made fb.plot.images more customizable.
1 parent 2343d58 commit c643f20

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

foolbox/plot.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,10 @@ def images(
1313
nrows: Optional[int] = None,
1414
figsize: Optional[Tuple[float, float]] = None,
1515
scale: float = 1,
16+
labels: Any = None,
17+
return_fig: bool = False,
1618
**kwargs: Any,
17-
) -> None:
19+
) -> Optional[Tuple[Any, Any]]:
1820
import matplotlib.pyplot as plt
1921

2022
x: ep.Tensor = ep.astensor(images)
@@ -57,7 +59,7 @@ def images(
5759
nrows=nrows,
5860
figsize=figsize,
5961
squeeze=False,
60-
constrained_layout=True,
62+
constrained_layout=False,
6163
**kwargs,
6264
)
6365

@@ -68,5 +70,10 @@ def images(
6870
ax.set_yticks([])
6971
ax.axis("off")
7072
i = row * ncols + col
73+
if labels is not None:
74+
ax.set_title(labels[i])
7175
if i < len(x):
7276
ax.imshow(x[i])
77+
78+
if return_fig:
79+
return fig, axes

0 commit comments

Comments
 (0)