Skip to content
This repository has been archived by the owner on Aug 1, 2024. It is now read-only.

Commit

Permalink
remove top and right spines
Browse files Browse the repository at this point in the history
  • Loading branch information
jeromedockes committed Jan 10, 2024
1 parent 8065d4d commit e298684
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
9 changes: 8 additions & 1 deletion src/skrubview/_plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@
COLOR_0 = COLORS[0]


def _despine(ax):
ax.spines[["top", "right"]].set_visible(False)


def _serialize(fig, close=True):
buffer = io.BytesIO()
fig.savefig(buffer, format="svg", bbox_inches="tight")
Expand All @@ -43,6 +47,7 @@ def _rotate_ticklabels(ax):
def histogram(col, title=None, color=COLOR_0):
values = np.asarray(col.to_array())
fig, ax = plt.subplots(figsize=(3, 1.5), layout="compressed")
_despine(ax)
ax.hist(values, color=color)
if title is not None:
ax.set_title(title)
Expand All @@ -54,6 +59,7 @@ def line(x_col, y_col):
x = np.asarray(x_col.to_array())
y = np.asarray(y_col.to_array())
fig, ax = plt.subplots(figsize=(3, 2), layout="compressed")
_despine(ax)
ax.plot(x, y)
ax.set_xlabel(x_col.name)
ax.set_ylabel(y_col.name)
Expand All @@ -67,11 +73,12 @@ def value_counts(value_counts, n_unique, color=COLOR_0):
height = 0.2 * (len(value_counts) + 1.1)
if n_unique > len(value_counts):
title = f"{len(value_counts)} most frequent out of {n_unique}"
height += .5
height += 0.5
else:
title = None
width = 0.1 * max(len(str(v)) for v in values) + 2
fig, ax = plt.subplots(figsize=(width, height), layout="compressed")
_despine(ax)
ax.barh(list(map(str, values)), counts, color=color)
if title is not None:
ax.set_title(title)
Expand Down
2 changes: 1 addition & 1 deletion src/skrubview/_summarize.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ def _add_numeric_summary(summary, column, with_plots, order_by_column):
return
if order_by_column is None:
summary["histogram_plot"] = _plotting.histogram(
column, "Value distribution", color=_plotting.COLORS[0]
column, title=None, color=_plotting.COLORS[0]
)
else:
summary["line_plot"] = _plotting.line(order_by_column, column)

0 comments on commit e298684

Please sign in to comment.