diff --git a/src/safeds/data/tabular/plotting/_table_plotter.py b/src/safeds/data/tabular/plotting/_table_plotter.py index bc5907c62..573dd258c 100644 --- a/src/safeds/data/tabular/plotting/_table_plotter.py +++ b/src/safeds/data/tabular/plotting/_table_plotter.py @@ -97,7 +97,7 @@ def correlation_heatmap(self) -> Image: # TODO: implement using matplotlib and polars # https://stackoverflow.com/questions/33282368/plotting-a-2d-heatmap import matplotlib.pyplot as plt - import seaborn as sns + import numpy as np only_numerical = self._table.remove_non_numeric_columns()._data_frame.fill_null(0) @@ -115,15 +115,18 @@ def correlation_heatmap(self) -> Image: " automatically expanding." ), ) - fig = plt.figure() - sns.heatmap( - data=only_numerical.corr().to_numpy(), + + fig, ax = plt.subplots() + heatmap = plt.imshow( + only_numerical.corr().to_numpy(), vmin=-1, vmax=1, - xticklabels=only_numerical.columns, - yticklabels=only_numerical.columns, - cmap="vlag", + cmap="coolwarm", ) + ax.set_xticks(np.arange(len(only_numerical.columns)), labels=only_numerical.columns) + ax.set_yticks(np.arange(len(only_numerical.columns)), labels=only_numerical.columns) + fig.colorbar(heatmap) + plt.tight_layout() return _figure_to_image(fig) diff --git a/tests/safeds/data/tabular/plotting/__snapshots__/test_plot_correlation_heatmap/test_should_match_snapshot[normal].png b/tests/safeds/data/tabular/plotting/__snapshots__/test_plot_correlation_heatmap/test_should_match_snapshot[normal].png index eedf2950c..9e6cfc072 100644 Binary files a/tests/safeds/data/tabular/plotting/__snapshots__/test_plot_correlation_heatmap/test_should_match_snapshot[normal].png and b/tests/safeds/data/tabular/plotting/__snapshots__/test_plot_correlation_heatmap/test_should_match_snapshot[normal].png differ