Skip to content

Commit 474d40c

Browse files
committed
feat: add show_yticklabels parameter to hide y-axis labels for shared axes
1 parent 77ead7d commit 474d40c

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/cellmapper/model/evaluate.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,7 @@ def plot_confusion_matrix(
214214
xlabel_position: Literal["bottom", "top"] = "bottom",
215215
show_grid: bool = True,
216216
min_cells: int | None = None,
217+
show_yticklabels: bool = True,
217218
**kwargs,
218219
) -> plt.Axes:
219220
"""
@@ -245,6 +246,9 @@ def plot_confusion_matrix(
245246
Minimum number of cells required for a category to be included in the confusion matrix.
246247
Categories with fewer cells in both true and predicted labels are filtered out.
247248
If None, all categories are shown.
249+
show_yticklabels
250+
Whether to show y-axis tick labels. Default is True. Set to False for the right
251+
subplot when sharing the y-axis between multiple confusion matrices.
248252
**kwargs
249253
Additional keyword arguments to pass to ConfusionMatrixDisplay.
250254
@@ -313,6 +317,11 @@ def plot_confusion_matrix(
313317
if not show_grid:
314318
ax.grid(False)
315319

320+
# Optionally hide y-axis tick labels (for shared y-axis in subplots)
321+
if not show_yticklabels:
322+
ax.set_yticklabels([])
323+
ax.set_ylabel("")
324+
316325
# Move x-axis labels to top if requested (when annotation colors are not shown)
317326
if xlabel_position == "top" and not show_annotation_colors:
318327
ax.xaxis.tick_top()

0 commit comments

Comments
 (0)