Skip to content

Commit 1ccb226

Browse files
committed
Fix legend overlap in publication figure
1 parent 84a1c6d commit 1ccb226

2 files changed

Lines changed: 4 additions & 5 deletions

File tree

docs/publication_figure.png

18.1 KB
Loading

scripts/06_publication_figures.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,22 +33,21 @@ def make_figure(adata):
3333
"""Create a multi-panel publication figure."""
3434
FIG_DIR.mkdir(parents=True, exist_ok=True)
3535

36-
fig = plt.figure(figsize=(16, 12))
37-
gs = gridspec.GridSpec(2, 3, figure=fig, hspace=0.35, wspace=0.35)
36+
fig = plt.figure(figsize=(18, 12))
37+
gs = gridspec.GridSpec(2, 3, figure=fig, hspace=0.4, wspace=0.45)
3838

3939
# A: UMAP by cluster
4040
ax_a = fig.add_subplot(gs[0, 0])
4141
sc.pl.umap(adata, color="leiden", legend_loc="on data", legend_fontsize=8,
4242
legend_fontoutline=2, frameon=False, ax=ax_a, show=False, title="")
4343
ax_a.set_title("A Leiden Clusters", fontsize=12, fontweight="bold", loc="left")
4444

45-
# B: UMAP by cell type
45+
# B: UMAP by cell type (legend on data to avoid overlap with panel C)
4646
ax_b = fig.add_subplot(gs[0, 1])
47-
# Build palette for present cell types
4847
present_types = adata.obs["cell_type"].cat.categories.tolist()
4948
palette = [PALETTE.get(ct, "#AAAAAA") for ct in present_types]
5049
sc.pl.umap(adata, color="cell_type", palette=palette,
51-
legend_loc="right margin", legend_fontsize=7,
50+
legend_loc="on data", legend_fontsize=6, legend_fontoutline=2,
5251
frameon=False, ax=ax_b, show=False, title="")
5352
ax_b.set_title("B Cell Types", fontsize=12, fontweight="bold", loc="left")
5453

0 commit comments

Comments
 (0)