ggdesplot(): position num/text labels correctly when the formula has no fill variable - #20
Merged
Merged
Conversation
With an empty formula LHS (no fill variable) ggdesplot() drew no tile, so the +-0.5 cell extent was never established and num/text labels on the outer cells were clipped at the panel border. Draw a transparent tile grid in that case, as the lattice path already does. Also assert the deliberate col.regions positional-fallback warning with expect_warning() instead of hiding it with suppressWarnings().
Owner
|
Excellent. Thanks. |
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.
Problem
Following up on your note that
ggdesplot(oats35, ~ col+row|block, num=gen)did not look right: with an empty formula left-hand side (no fill variable)ggdesplot()adds nogeom_tile, so nothing establishes the ±0.5 cell extent. Thenum/textlabels on the outer cells then sit exactly on the panel border and get clipped, whereas the latticedesplot()reserves that extent regardless of fill.Reproducer (against the current
main)The gg panels' x-range collapses to the outer column centres (e.g.
[3, 4]for a two-column block), so a label at either column lands on the border.Fix
Draw an invisible (
fill = "transparent") tile grid in the no-fill case, mirroring what the lattice path already does. The extent then reaches half a cell beyond the outer centres and the labels are centred. Guarded byfill.type == "none", so filled plots are untouched. Added a regression test that checks the panel x-range covers the full cell extent and that a tile layer is present.This branch also folds in a small follow-up to your
suppressWarnings()cleanup: the one remainingsuppressWarnings()(the deliberatecol.regionspositional-fallback warning) is now asserted withexpect_warning(..., "positional")instead of being hidden.Related to your comment on the
ggdesplot(oats35, ~ col+row|block, num=gen)line intest_desplot.R.Prepared with the help of an AI coding assistant; the reproducer above was run and verified locally.