Skip to content

Smart x/ylim arguments#644

Merged
grantmcdermott merged 8 commits into
mainfrom
smart-xylim-616
Jun 29, 2026
Merged

Smart x/ylim arguments#644
grantmcdermott merged 8 commits into
mainfrom
smart-xylim-616

Conversation

@grantmcdermott

Copy link
Copy Markdown
Owner

Fixes #616

MWE

Reference plot for comparison.

pkgload::load_all("~/Documents/Projects/tinyplot/")
#> ℹ Loading tinyplot
plt(dist ~ speed, data = cars)

  1. Scalar input ensures value coverage (here: x value is binding, but the y value isn't).
plt(dist ~ speed, data = cars, xlim = 0, ylim = 100)

  1. Partial NA pins one limit, let data set the other.
plt(dist ~ speed, data = cars, xlim = c(0, NA))

  1. "rev(erse)" keyword
plt(dist ~ speed, data = cars, xlim = "reverse")

Created on 2026-06-23 with reprex v2.1.1

@grantmcdermott

Copy link
Copy Markdown
Owner Author

@zeileis @vincentarelbundock Sorry to tag you (again!) but I promise that this is the final time before I submit 0.7.0. I'd like your feedback, since this is an API change (which I like, but you might feel differently).

I'm confident in the implementation, so no need to check the internal code. Just let me know whether you like the API.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR implements “smart” xlim/ylim override forms in tinyplot, adding support for scalar coverage (ensure a value is included), partial-NA limit pinning, and a "rev(erse)" keyword to reverse automatically computed axis limits (Fixes #616).

Changes:

  • Extend xlim/ylim parsing to support scalar inputs, length-2 partial NA, and "rev(erse)" keyword reversal.
  • Plumb new rev_x/rev_y flags through settings, limit computation, flip handling, and facet drawing (including free-scale facets).
  • Add snapshot tests and documentation/NEWS updates describing the new limit behaviors.

Reviewed changes

Copilot reviewed 7 out of 13 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
R/zzz.R Registers new rev_x/rev_y globals to satisfy R CMD check.
R/tinyplot.R Adds docs for new xlim/ylim forms; resolves "rev(erse)" into rev_x/rev_y settings.
R/lim.R Adds resolve_lim() and applies smart limit resolution; reverses finalized limits based on rev_x/rev_y.
R/flip.R Ensures rev_x/rev_y are swapped when flipping axes.
R/facet.R Threads rev_x/rev_y into facet window drawing; attempts to support reversed axes under free facets.
NEWS.md Documents the new “smart” x/ylim override forms.
man/tinyplot.Rd Updates rendered documentation for new xlim/ylim behaviors.
man/facet.Rd Documents new internal rev_x/rev_y parameters for draw_facet_window().
inst/tinytest/test-lim.R Adds snapshot tests covering scalar coverage, partial-NA pinning, and "reverse" (incl. free facets).
inst/tinytest/_tinysnapshot/lim_scalar_zero.svg New snapshot output for scalar coverage test.
inst/tinytest/_tinysnapshot/lim_reverse.svg New snapshot output for reverse keyword test.
inst/tinytest/_tinysnapshot/lim_reverse_free_facet.svg New snapshot output for reverse keyword with free facets.
inst/tinytest/_tinysnapshot/lim_partial_na.svg New snapshot output for partial-NA pinning test.
Files not reviewed (2)
  • man/facet.Rd: Generated file
  • man/tinyplot.Rd: Generated file

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread R/facet.R Outdated
Comment thread NEWS.md Outdated
@grantmcdermott grantmcdermott merged commit d7e035e into main Jun 29, 2026
4 of 5 checks passed
@grantmcdermott grantmcdermott deleted the smart-xylim-616 branch June 29, 2026 03:35
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.

Smart x/ylim overrides

2 participants