grantmcdermott · GitHub

added 7 commits

June 1, 2026 16:53
When legend="top!" is combined with a dynmar theme (e.g.,
theme="dynamic"), the title and legend now render correctly:
title above legend, legend above plot region.
Key changes:
- Pass dynmar_computed[3] as dynmar_title_mar to draw_legend so
  tinylegend's replay produces a mar[3] large enough for title()
- Update dynmar_computed[3] after draw_legend so draw_facet_window
  doesn't draw the plot region over the legend
- Add dedicated dynmar + adj_title path in draw_title using soma
- Fix restore_margin_inner to detect dirty margins from par("mar")
  directly (omd reset clears oma as a side-effect)
- Keep .theme_mar[3] for "top!" (unlike other outer sides which use oma)
Skip the oma[3] += topmar_epsilon adjustment when dynmar_title_mar
is active. This eliminates the 0.2-line outer margin that was
shifting the figure region down, causing the title to sit ~2.9pt
lower than with other legend positions.
The topmar_epsilon in oma[3] was originally a dirty-state signal
for restore_margin_inner, now handled by direct mar detection.
When side.sub=3 (subtitle on top), bump line_sub by soma so the
subtitle renders above the legend, maintaining the correct stacking
order: title → subtitle → legend → plot.

@grantmcdermott

Read the original on github.com ↗