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: replace seaborn with matplotlib for box_plot #863

Merged
merged 18 commits into from
Jun 28, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
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
16 changes: 8 additions & 8 deletions docs/tutorials/data_visualization.ipynb
Muellersen marked this conversation as resolved.
Show resolved Hide resolved

Large diffs are not rendered by default.

19 changes: 12 additions & 7 deletions src/safeds/data/tabular/plotting/_table_plotter.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,17 +61,24 @@ def box_plots(self) -> Image:

columns = numerical_table.to_columns()
columns = [column._series.drop_nulls() for column in columns]
number_of_columns = 3
max_width = 3
number_of_columns = len(columns) if len(columns) <= max_width else max_width
number_of_rows = ceil(len(columns) / number_of_columns)

fig, axs = plt.subplots(nrows=number_of_rows, ncols=number_of_columns)
fig.set_size_inches(10, 6)

line = 0
for i, column in enumerate(columns):
if i % number_of_columns == 0 and i != 0:
line += 1

if number_of_columns == 1:
axs.boxplot(
column,
patch_artist=True,
labels=[numerical_table.column_names[i]],
)
break

if number_of_rows == 1:
axs[i].boxplot(
column,
Expand All @@ -89,13 +96,11 @@ def box_plots(self) -> Image:
# removes unused ax indices, so there wont be empty plots
last_filled_ax_index = len(columns) % number_of_columns
for i in range(last_filled_ax_index, number_of_columns):
if number_of_rows == 1:
fig.delaxes(axs[i])
else:
if number_of_rows != 1 and last_filled_ax_index != 0:
fig.delaxes(axs[number_of_rows - 1, i])

fig.tight_layout()

_figure_to_image(fig).to_png_file("C:/Users/patri/Desktop/test.png")
Muellersen marked this conversation as resolved.
Show resolved Hide resolved
return _figure_to_image(fig)

def correlation_heatmap(self) -> Image:
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading