Skip to content

Commit

Permalink
aspect ratio calculation was performed backwards. Solved bug in Param…
Browse files Browse the repository at this point in the history
…Grid with new aspect ratio argument
  • Loading branch information
eugenioLR committed Jul 12, 2024
1 parent 5482349 commit 51e56a0
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/seaborn_image/_grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ def __init__(

# Select minimum aspect ratio among all the images
for img in data:
aspect_aux = img.shape[0] / img.shape[1]
aspect_aux = img.shape[1] / img.shape[0]
if aspect_aux < aspect:
aspect = aspect_aux

Expand All @@ -395,7 +395,7 @@ def __init__(
col_wrap = len(map_func) if col_wrap is None else col_wrap

if aspect == "auto":
aspect = data.shape[0] / data.shape[1]
aspect = data.shape[1] / data.shape[0]

elif data.ndim in [3, 4]:
if data.ndim == 4 and data.shape[-1] not in [1, 3, 4]:
Expand Down Expand Up @@ -432,7 +432,7 @@ def __init__(

if aspect == "auto":
# Select axis where width and height are
width_idx, height_idx = [i for i in range(data.ndim) if i != axis][:2]
height_idx, width_idx = [i for i in range(data.ndim) if i != axis][:2]

aspect = data.shape[width_idx] / data.shape[height_idx]

Expand Down Expand Up @@ -1192,6 +1192,9 @@ def __init__(
nrow = int(np.ceil(len(kwargs[f"{col}"]) / col_wrap))

# Calculate the base figure size
if aspect == "auto":
aspect = data.shape[1]/data.shape[0]

figsize = (ncol * height * aspect, nrow * height)

fig = plt.figure(figsize=figsize)
Expand Down

0 comments on commit 51e56a0

Please sign in to comment.