Skip to content
Merged
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
21 changes: 9 additions & 12 deletions sofic/viz/idiagram.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ def plot_information_diagram(
)

if figsize is None:
figsize = (max(9.0, 0.55 * n + 1.2), 5.6)
figsize = (max(9.0, 0.55 * n + 1.2), 6.4)
n_legend = len(handles_by_group)
ncol = _legend_ncols(figsize[0], n_legend)
empty_patch = mpatches.Patch(facecolor="none", edgecolor="none", label=" ")
Expand Down Expand Up @@ -300,16 +300,11 @@ def plot_information_diagram(
for x, atom in zip(xs, plotted, strict=True):
inside = set(atom.indices)
color = colors[atom.role]
ys_inside = []
ax_mat.plot([x, x], [0, n_vars - 1], color=color, lw=2.0, zorder=2)
for var_index in range(n_vars):
y = n_vars - 1 - var_index
if var_index in inside:
ax_mat.plot(x, y, "o", color=color, ms=8, zorder=3)
ys_inside.append(y)
else:
ax_mat.plot(x, y, "o", color="0.86", ms=8, zorder=2)
if len(ys_inside) > 1:
ax_mat.plot([x, x], [min(ys_inside), max(ys_inside)], color=color, lw=2.0, zorder=2)
face = color if var_index in inside else "white"
ax_mat.plot(x, y, "o", mfc=face, mec=color, mew=1.5, ms=8, zorder=3)

ax_mat.set_xlim(-1.4, n - 0.5)
# First gray strip is the top row at y = n_vars - 1, spanning
Expand All @@ -319,8 +314,9 @@ def plot_information_diagram(
ax_mat.set_ylim(-0.5, top)
ax_mat.axhline(top, color="0.15", lw=1.0, solid_capstyle="butt", zorder=10)
ax_mat.set_yticks([])
ax_mat.set_xticks([])
ax_mat.tick_params(axis="x", bottom=False, labelbottom=False)
ax_mat.set_xticks(xs)
ax_mat.set_xticklabels([atom.jurgens_label or atom.label for atom in plotted], rotation=90, fontsize=8)
ax_mat.tick_params(axis="x", length=0, pad=4)
for spine in ax_mat.spines.values():
spine.set_visible(False)

Expand All @@ -339,7 +335,8 @@ def plot_information_diagram(
title_fontsize=8,
)

fig.subplots_adjust(left=0.075, right=0.98, top=0.93, bottom=0.05)
# Reserve a fixed ~0.85 in strip at the bottom for the rotated atom labels.
fig.subplots_adjust(left=0.075, right=0.98, top=0.93, bottom=0.85 / figsize[1])
# After layout, seat the matrix flush under the bar so the bar x-axis
# (bottom spine) borders the top of the first gray strip.
bar_pos = ax_bar.get_position()
Expand Down
Loading