Skip to content

Fix/g forest header row alignment - #1546

Open
gwangjinkim wants to merge 2 commits into
pharmaverse:mainfrom
gwangjinkim:fix/g-forest-header-row-alignment
Open

gwangjinkim wants to merge 2 commits into
pharmaverse:mainfrom
gwangjinkim:fix/g-forest-header-row-alignment

Conversation

@gwangjinkim

Copy link
Copy Markdown
Contributor

Pull Request

Fixes #1543

Cause

g_forest() only handled a two-row table header correctly:

  • Forest plot row positions subtracted as.numeric(nlines_hdr == 2), so a 3-row header shifted the points up by two rows.
  • The table's y-axis expansion was removed only when nlines_hdr == 2, so a 1-row header drifted slightly against the plot.

Changes

  • R/g_forest.R: body row i is now always drawn at nrows_body - i + 1, independent of the header height. The table's y-axis expansion is applied unconditionally.
  • Tests: added a snapshot-free regression test comparing y positions of table rows and forest points for 1-, 2- and 3-row headers (fails on main, passes with the fix). The forest_grob() / forest_viewport() deprecation tests now use a collect_deprecations() helper, because newer lifecycle versions deduplicate repeated warnings.
  • Snapshots: updated the 19 g_forest snapshots for one-row-header tables. Only the y coordinates of the table text change.
  • NEWS entry added.

Testing

test-g_forest.R passes (19/19, no warnings) with Arial installed and a UTF-8 locale.

Note: with current svglite (2.2.2) and this font setup, 25 graphics snapshot tests in other files fail identically on an unmodified main. They are unrelated to this PR and are not touched here.

claude added 2 commits October 8, 2026 11:19
…verse#1543)

The forest plot row positions subtracted a fixed offset that was only
correct for a two-row table header, and the table's y-axis expansion was
removed only in that case. Body row i is now always placed at
`nrows_body - i + 1` and the y-axis expansion is removed unconditionally,
so rows line up for any header height.

Adds a snapshot-free regression test comparing the y positions of table
rows and forest points for 1-, 2- and 3-row headers.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Hu112DJEVzgWdVGVuiYj7x
…n agnostic

Update the 19 g_forest snapshots for one-row-header tables: with the
alignment fix only the y coordinates of the table text change (regenerated
with Arial, the font the committed snapshots use).

The forest_grob()/forest_viewport() tests nested a fixed number of
expect_deprecated() calls, which breaks when the installed lifecycle
version deduplicates repeated warnings from internal helpers. Collect all
deprecation warnings instead and assert on the function under test.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Hu112DJEVzgWdVGVuiYj7x

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: g_forest() is misaligned with table values when header height is not 2.

2 participants