Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: replaced seaborn with matplotlib for correlation_heatmap #850

Merged
merged 3 commits into from
Jun 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions src/safeds/data/tabular/plotting/_table_plotter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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)
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.