diff --git a/src/safeds/data/tabular/containers/_table.py b/src/safeds/data/tabular/containers/_table.py index 368f6c782..7eea71f1c 100644 --- a/src/safeds/data/tabular/containers/_table.py +++ b/src/safeds/data/tabular/containers/_table.py @@ -2175,8 +2175,12 @@ def plot_histograms(self, *, number_of_bins: int = 10) -> Image: n_cols = min(3, self.number_of_columns) n_rows = 1 + (self.number_of_columns - 1) // n_cols - one_col = n_cols == 1 and n_rows == 1 - fig, axs = plt.subplots(n_rows, n_cols, tight_layout=True, figsize=(n_cols * 3, n_rows * 3)) + if n_cols == 1 and n_rows == 1: + fig, axs = plt.subplots(1, 1, tight_layout=True) + one_col = True + else: + fig, axs = plt.subplots(n_rows, n_cols, tight_layout=True, figsize=(n_cols * 3, n_rows * 3)) + one_col = False col_names = self.column_names for col_name, ax in zip(col_names, axs.flatten() if not one_col else [axs], strict=False): diff --git a/tests/safeds/data/tabular/containers/_table/__snapshots__/test_plot_histograms/test_should_match_snapshot[one column].png b/tests/safeds/data/tabular/containers/_table/__snapshots__/test_plot_histograms/test_should_match_snapshot[one column].png index 6bab3cef0..eb3113704 100644 Binary files a/tests/safeds/data/tabular/containers/_table/__snapshots__/test_plot_histograms/test_should_match_snapshot[one column].png and b/tests/safeds/data/tabular/containers/_table/__snapshots__/test_plot_histograms/test_should_match_snapshot[one column].png differ