Skip to content
Snippets Groups Projects
Commit d783f901 authored by Alán Muñoz's avatar Alán Muñoz
Browse files

change(plot): add set_data support

parent ac7f44a8
No related branches found
No related tags found
No related merge requests found
...@@ -13,13 +13,20 @@ from matplotlib import pyplot as plt ...@@ -13,13 +13,20 @@ from matplotlib import pyplot as plt
def plot_overlay( def plot_overlay(
bg: np.ndarray, fg: np.ndarray, alpha: float = 0.5, ax=plt bg: np.ndarray, fg: np.ndarray, alpha: float = 0.5, ax=plt
) -> None: ) -> None:
"""
Plot two images, one on top of the other.
"""
ax.imshow(bg, cmap=plt.cm.gray, interpolation="none") ax1 = ax.imshow(bg, cmap=plt.cm.gray, interpolation="none")
ax.imshow(fg, alpha=alpha, interpolation="none") ax2 = ax.imshow(fg, alpha=alpha, interpolation="none")
ax.axis("off") plt.axis("off")
return ax1, ax2
def plot_overlay_in_square(data: t.Tuple[np.ndarray, np.ndarray]): def plot_overlay_in_square(data: t.Tuple[np.ndarray, np.ndarray]):
"""
Plot images in an automatically-arranged grid.
"""
specs = strategies.SquareStrategy("center").get_grid(len(data)) specs = strategies.SquareStrategy("center").get_grid(len(data))
for i, (gs, (tile, mask)) in enumerate(zip(specs, data)): for i, (gs, (tile, mask)) in enumerate(zip(specs, data)):
ax = plt.subplot(gs) ax = plt.subplot(gs)
...@@ -27,6 +34,9 @@ def plot_overlay_in_square(data: t.Tuple[np.ndarray, np.ndarray]): ...@@ -27,6 +34,9 @@ def plot_overlay_in_square(data: t.Tuple[np.ndarray, np.ndarray]):
def plot_in_square(data: t.Iterable): def plot_in_square(data: t.Iterable):
"""
Plot images in an automatically-arranged grid. Only takes one mask
"""
specs = strategies.SquareStrategy("center").get_grid(len(data)) specs = strategies.SquareStrategy("center").get_grid(len(data))
for i, (gs, datum) in enumerate(zip(specs, data)): for i, (gs, datum) in enumerate(zip(specs, data)):
ax = plt.subplot(gs) ax = plt.subplot(gs)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment