Repository navigation
Fit the text of three showcase figures to their size (#108) - #123
Merged
Merged
Conversation
A ggplot does not know the size it will be drawn at, so captions, subtitles, and keys are broken into lines when the figure is made. The helper breaks them for a figure 7 inches wide, the narrowest width at which the vignettes draw the package's figures, with 6.8 inches of text inside the plot margins. The characters per line assume 0.55 em per character, so that a line also fits in DejaVu Sans (about 0.51 em on the package's captions), the default sans-serif font on Linux and on the pkgdown site; Arial and Helvetica are about 0.45 em. .wrap_figure_text() wraps between words and keeps existing line breaks; .fill_figure_text() breaks only between given pieces, so that a path or a group label is never split. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
At the sizes the vignettes and the reference page use, the caption was cut off, removing the caution of Sawilowsky et al. (1994), and the "not significant" edge labels sat on the nodes; at the pkgdown default of 7.29 by 4.51 inches the nodes of the fitted path overlapped. - The caption and the subtitle are broken into lines for a 7-inch figure; the path in the subtitle is never split. Captions start at the left edge of the figure, and the figure has the usual plot margins, which theme_void() lacks. - Edge labels are set beside the arrows: to the right of a vertical arrow, and above the midpoint of an arrow leaving Test A on the side it leads to. Arrows run from the bottom of one node to the top of the next, using an estimate of each node's height. - A visited test's p-value is set beside its name, so that a visited node is no taller than the others and the tree fits a 4.5-inch figure. - The y range follows the number of levels, so the 1995 flow no longer leaves an empty band at the bottom. Two existing expectations change because the old output was the problem: the caption is now compared with its line breaks replaced by spaces, and the selected test's label is "Test F (p = ...)\nGain-score treatment effect" instead of having the p-value on a third line. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The four-group caption was one line of about 130 characters, cut off at both ends at 7 inches. It is now set one or two sentences to a line, as the caption for several treatments already was, and each line is wrapped for a 7-inch figure; it starts at the left edge of the figure. The four groups are set two by two in the colour legend, which was cut off at 7 inches in DejaVu Sans; the legends now always come in the same order, groups first. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The four-group key was aligned with the panel and ran off the right edge of the figure most users see first, and the group sizes and means, drawn in data coordinates beyond the tiles, were cut off at 7.29 inches. - The title and key start at the left edge of the figure for every design, with the notation on the first line and "X = treatment" on the second, as the figures of designs with several treatments already had. - The caption starts at the left edge; the flagged groups are broken only between groups, and the rule is wrapped. - The rows are drawn at integer positions on a continuous scale, so that an invisible secondary axis carrying the same text as the group summaries makes ggplot2 set aside their width. They can no longer be cut off, whatever the figure size or font. (Secondary axes on discrete scales need ggplot2 4.0.0; continuous ones work in every version.) - Each summary is set on two lines, "n = 30" and "posttest mean 56.23", so that the schematic keeps room for its column headings. The test that the four-group figure keeps plot.title.position = "panel" now expects "plot": the panel alignment was what cut off the key. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A dependency-free layout test builds plot_classic_flow(), plot_solomon_change(), and plot_solomon_design() on a pdf(NULL) device at the sizes the vignettes use (7 x 5.5, 8 x 5, 7 x 4.5, 8 x 3.5, 7 x 4.2, and 7.29 x 3.5 inches) and at the pkgdown default of 7.29 x 4.51 inches, and checks from the gtable that: - no title, subtitle, caption, or legend is wider than its cell; - no edge label of the decision path covers a node, no two nodes overlap, and each arrow's head meets its node without being hidden; - plot_solomon_design() sets aside the width of its group summaries, and its column headings do not run into each other. The pdf() device measures with Helvetica metrics, the same on every platform; text widths are multiplied by 1.15 so that the checks also hold for DejaVu Sans. On the plotting code before this branch, the test gives 27 failures and 1 error. NEWS.md records the changes; DejaVu is added to the word list. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
) Review finding: the arrow ends used a fixed node half-height in y units, tuned for a four-line caption. The fitted 1990 flow has a six-line caption and so a shorter panel, and at 7.29 x 4.51 and 7 x 4.5 inches every arrowhead ended 0.011 to 0.031 inch inside the node it points to, beyond the layout test's own tolerance; no fitted 1990 flow was among the arrow cases. The half-height is now computed in inches and converted with an estimate of the y unit at 4.5 inches high, the smallest height the figure is laid out for. The estimate follows the lines of the subtitle and the caption: the title, margins, and spacing take 0.546 inch, and each line of the subtitle or caption takes 1.08 times its point size (line height 0.9 in lines 1.2 times the text size), as measured on the pdf() device. A node is 1.2 * (lines - 1) + 1.46 times its text size high, the box the layout helper models. Arrows stop 0.01 inch short of their nodes at 4.5 inches high, for every flow and caption length, and a little more in taller figures (at most 0.097 inch at 7 x 5.5). Tests: the arrow cases add the fitted 1990 flow at 7.29 x 4.51, 7 x 4.5, and 7 x 5.5 inches, and a new test checks the panel-height estimate against the drawn panel at 7 x 4.5 inches for captions of two to six lines, and that every arrow there stops 0.01 inch short of its nodes. Both fail on the previous code. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ws (#108) Review findings on the group sizes and means beside the schematic: - Their width was set aside by a secondary axis carrying the same text, made transparent by the plot's theme. A complete theme added to the returned plot, such as theme_bw(), replaced that setting, so the axis labels showed through and every summary was drawn twice, offset. The axis is now hidden by the theme of its own guide (guide_axis(theme =)), which a theme added to the plot does not replace; its ticks and line are blank there too. This needs ggplot2 3.5.0, now the floor in DESCRIPTION (the package already needed 3.4.0 for the linewidth aesthetic). - Each summary was always two lines, which ran into the summaries above and below in a design with ten or more groups. Up to eight groups keep two lines, now with a line height of 0.9 so that each pair reads as one group; with ten or more, each summary takes one line, as before #108. With one line, the headings of a ten- or twelve-group schematic at 7.29 inches fit with the pdf() metrics but not with the full allowance for DejaVu Sans; with two lines the rows of such designs are too short. - The rows are drawn at 1, 2, ... on a continuous y scale, so that the secondary axis works on ggplot2 before 4.0.0; a layer keyed by group label now needs the row's position. The help page and NEWS say so and show match(label, levels(p$data$row)). - The key to the treatment marks had its own 64-character rule. It now calls .fill_figure_text() at the subtitle size, the rule of all other figure text (74 characters). Tests: - p + theme_bw(), theme_classic(), theme_grey(), theme_void(), and a theme recolouring the axis text each draw every summary exactly once, with no ticks or line on the right, for four and ten groups; the width stays set aside under theme_bw(). On the previous code, each summary is drawn twice. - Neighbouring summaries are at least twice as far apart as the lines of one summary, for four to twelve groups, with and without flagged groups, at 7.29 x 4.51 inches and the vignette sizes. On the previous code, the designs with eight or more groups fail. - Known-result tests of the one- and two-line summaries, of the row positions and the secondary-axis labels, and of a layer added by group label, as the help page shows. - The key test in test-ngroup-plots.R changes its expectation: the twelve-group key now breaks after X4 rather than after X3, and its lines are checked against the 74-character rule instead of 64. The old rule was a second, narrower rule for one piece of figure text; the layout test checks that the key fits at 7 x 4.5 and 7.29 x 4.51 inches with the allowance for DejaVu Sans. A boundary test pins the rule: a key of 74 characters keeps one line, one of 75 is broken. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
NEWS: this branch's sections go under the development heading, above the 0.8.1 section. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
NEWS: this branch's section goes first under the development heading. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
JUhalt
added a commit
that referenced
this pull request
Oct 4, 2026
NEWS: this branch's section goes first under the development heading. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
JUhalt
added a commit
that referenced
this pull request
Oct 4, 2026
NEWS: this branch's sections go first under the development heading. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #108.
plot_classic_flow(),plot_solomon_change(), andplot_solomon_design()use it. Their captions, subtitles, and keys no longer clip at the sizes the vignettes use, or at the pkgdown default width.plot_classic_flow(). Its caption keeps the full Sawilowsky et al. (1994) caution. Edge labels no longer sit on nodes, and arrows stop short of their nodes in every flow (fixed after review for the fitted 1990 flow).plot_solomon_design(). Its group summaries are drawn once even under a complete theme such astheme_bw(), which was fixed after review. That fix needsggplot2 (>= 3.5.0); the package already needed 3.4.0, undeclared, forlinewidth. Summaries stay on two lines up to 8 groups and on one line from 10 groups. Its rows now sit on a continuous y scale at positions 1, 2, and so on;@returnand NEWS say how to add layers by group label.Checks
tools/check-references.Rand the spelling check are clean.Review. An independent reviewer checked the branch against the issues' acceptance criteria and re-ran its statistics. Every confirmed finding was then fixed, with tests.
🤖 Generated with Claude Code