tidyverse / tidyverse/ggplot2

Reconsider clipping padding for geometry-dependent OOB cases

Open
#6,892 9 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
R
Stars
7k
Forks
2.1k
Avg merge
59m
Merged PRs (30d)
2

Description

Following up on #6881, I wanted to clarify one limitation of handling this through oob.

The existing oob functions are very useful and solve many out-of-bounds problems, but none gives the desired result for a survival curve truncated at an arbitrary follow-up time. Censoring removes the first observation beyond the limit, so geom_step() cannot extend the final step to the boundary; squishing moves subsequent observations onto the boundary and can introduce unwanted steps there; and keeping the observations preserves the correct geometry but returns to the original clipping problem.

More importantly, this cannot be solved cleanly by simply adding a survival-specific x-scale oob function. To truncate a step curve correctly, the endpoint at the x-limit must retain the preceding y-value, and with multiple curves this must also be done within each group. That requires information about how the geom constructs its geometry, not just the out-of-bounds x-values available to the scale.

This illustrates a broader issue: some specialised geometries may require geom-specific handling of out-of-bounds observations. Relying on oob for these cases could therefore require separate solutions at different levels of the plotting pipeline rather than a general scale-level mechanism.

That is where a small optional clipping allowance could still be valuable as a last-resort mechanism. It would allow the full data to construct the correct geometry and then clip that geometry just outside the panel, without requiring specialised preprocessing or geom-specific handling for each case.

Would this be a reason to reconsider reopening #6881? I also completely understand if this kind of fallback is considered too specialised for ggplot2 itself and better suited to an extension package.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with issue #6881 and review how the existing oob handling, geom_step(), and x-scale behavior interact for truncated survival curves. Determine whether an optional clipping allowance is appropriate for geometry-dependent cases and what design would preserve grouped step endpoints; done means the project reaches a clear decision on reopening the proposal.

Written by the indexing model from the issue text.

Assessment

Tech stack
r
Domain
data-visualization
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Active
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.