Skip to content

Add overloaded ticks and a panel.border switch to desplot() and ggdesplot() - #19

Merged
kwstat merged 2 commits into
kwstat:mainfrom
SchmidtPaul:tick-border-args
Aug 7, 2026
Merged

Add overloaded ticks and a panel.border switch to desplot() and ggdesplot()#19
kwstat merged 2 commits into
kwstat:mainfrom
SchmidtPaul:tick-border-args

Conversation

@SchmidtPaul

Copy link
Copy Markdown
Collaborator

Motivation

FielDHub renders its field books with desplot and then post-processes the returned plot to get two things desplot cannot currently express directly: a tick at every integer field coordinate, and no panel border (a cleaner field map). This came up in DidierMurilloF/FielDHub#72, where the goal is to let FielDHub drop that post-processing and call desplot natively. Both are generally useful, so they belong in desplot.

What this adds

Two arguments, in both desplot() and ggdesplot(), fully backward compatible:

  • ticks is overloaded. In addition to the existing logical FALSE (default, no axes) and TRUE (default "pretty" breaks), it now accepts:
    • "all" - a break at every integer coordinate, resolved separately for each axis;
    • list(x =, y =) - explicit per-axis control, where each element is a numeric vector of breaks or "all"; a missing element leaves that axis at the default breaks.
  • panel.border = TRUE (default: current behaviour). FALSE omits the panel border and axis lines.

Example

library(desplot)
library(agridat)
data(yates.oats)

# Integer ticks on both axes and no panel border, directly from desplot:
desplot(yates.oats, yield ~ col + row, ticks = "all", panel.border = FALSE)

# Per-axis: integer breaks on x, default breaks on y (lattice or gg):
ggdesplot(yates.oats, yield ~ col + row, ticks = list(x = "all"))

Previously ticks was logical only, and the panel border was always drawn - reproducing the map above meant editing the returned object by hand.

Notes

  • Both the lattice and the ggplot2 path honour the two arguments. In the lattice path, panel.border = FALSE also drops the tick marks (border, axis line and ticks share axis.line there); the axis labels remain.
  • Docs (@param ticks, new @param panel.border, one example), a NEWS entry, and regression tests for both paths are included. Full test suite passes; R CMD check is clean.

Prepared with the help of an AI coding assistant; the example above was run and verified locally.

… pending)

Add a panel.border=TRUE argument (FALSE omits the panel border and axis
lines) and overload ticks= to accept, besides the logical FALSE/TRUE, the
string "all" (a break at every integer coordinate, resolved per axis) and
a list(x=, y=) for explicit per-axis breaks (each element numeric or "all";
a missing element keeps that axis at the default breaks).

Fully implemented and tested in ggdesplot(); desplot() gains the argument in
its signature and passes it through when gg=TRUE. The lattice (gg=FALSE) path
does not yet honour the overloaded ticks / panel.border - to follow, together
with document() and R CMD check.

5 new regression tests in test_ggdesplot_fixes.R; full suite 51 pass, 0 fail.
The overloaded 'ticks' (FALSE/TRUE/"all"/list(x=,y=)) and the new 'panel.border' switch were only wired into ggdesplot(); the lattice path ignored them. Resolve 'ticks' via .resolve_ticks() into the scales' draw/at, and drop the panel box + axis lines for panel.border=FALSE by merging axis.line into any par.settings passed through '...'. Import stats::update. Adds docs, NEWS, and lattice regression tests.
@kwstat

kwstat commented Aug 7, 2026

Copy link
Copy Markdown
Owner

Looks reasonable. Let me know when you want a new version released to cran. It's been more than a year since the last release. (I try to release only a few times per year.)

@kwstat
kwstat merged commit 5df8040 into kwstat:main Aug 7, 2026
@SchmidtPaul

SchmidtPaul commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator Author

Thanks for merging! Yes, a CRAN release would be very welcome whenever it suits you. As you may have seen in the FielDHub thread, the refactor over there depends on these new arguments being on CRAN, so once desplot 1.11 is up I can get straight to it. No rush on the timing though.

EDIT: Ah, let me fix a few more things here, first.

EDIT2: Done - I've opened #20 with the fix (it also turns the last remaining suppressWarnings() into an asserted expect_warning()). Once you're happy with it, a CRAN release is very welcome from my side, whenever it suits you.

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.

2 participants