Add overloaded ticks and a panel.border switch to desplot() and ggdesplot() - #19
Merged
Conversation
… 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.
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.) |
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. |
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.
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()andggdesplot(), fully backward compatible:ticksis overloaded. In addition to the existing logicalFALSE(default, no axes) andTRUE(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).FALSEomits the panel border and axis lines.Example
Previously
tickswas logical only, and the panel border was always drawn - reproducing the map above meant editing the returned object by hand.Notes
panel.border = FALSEalso drops the tick marks (border, axis line and ticks shareaxis.linethere); the axis labels remain.@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 checkis clean.Prepared with the help of an AI coding assistant; the example above was run and verified locally.