Skip to content

Commit 9a9d9ba

Browse files
author
miranov25
committed
Phase 13.12.DF v1.2: Fix auto-title/subtitle overlap
apply_auto_title: render subtitle first at y=1.01, then set main title with pad=20 when subtitle present (pad=6 otherwise). Prevents overlap between main title and selection subtitle.
1 parent 75609ea commit 9a9d9ba

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

UTILS/dfextensions/dfdraw/plots/_auto_title.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,12 +114,16 @@ def apply_auto_title(ax, title_dict, fontsize=None, sub_fontsize=None):
114114
if sub_fontsize is None:
115115
sub_fontsize = get_style_value("auto_title.sel_fontsize", 8)
116116

117-
if title_dict.get("main"):
118-
ax.set_title(title_dict["main"], fontsize=fontsize)
119-
if title_dict.get("sub"):
117+
has_sub = bool(title_dict.get("sub"))
118+
if has_sub:
119+
# Subtitle between plot frame and main title
120120
ax.text(0.5, 1.01, title_dict["sub"],
121121
transform=ax.transAxes, fontsize=sub_fontsize,
122122
ha='center', va='bottom', style='italic', color='0.4')
123+
if title_dict.get("main"):
124+
# Push main title up when subtitle present to avoid overlap
125+
pad = 20 if has_sub else 6
126+
ax.set_title(title_dict["main"], fontsize=fontsize, pad=pad)
123127

124128

125129
def resolve_auto_title(auto_title):

0 commit comments

Comments
 (0)