Skip to content

Commit

Permalink
Fix visualization for subject with many images
Browse files Browse the repository at this point in the history
As reported by @cepa995 in #652.
  • Loading branch information
fepegar committed Sep 5, 2021
1 parent 99e6cfe commit 62cc8cb
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions torchio/visualization.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,16 +110,16 @@ def plot_subject(
**kwargs,
):
_, plt = import_mpl_plt()
num_images = len(subject)
many_images = num_images > 2
subplots_kwargs = {'figsize': figsize}
try:
if clear_axes:
subject.check_consistent_spatial_shape()
subplots_kwargs['sharex'] = 'col'
subplots_kwargs['sharey'] = 'col'
subplots_kwargs['sharex'] = 'row' if many_images else 'col'
subplots_kwargs['sharey'] = 'row' if many_images else 'col'
except RuntimeError: # different shapes in subject
pass
num_images = len(subject)
many_images = num_images > 2
args = (3, num_images) if many_images else (num_images, 3)
fig, axes = plt.subplots(*args, **subplots_kwargs)
# The array of axes must be 2D so that it can be indexed correctly within
Expand Down

0 comments on commit 62cc8cb

Please sign in to comment.