Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

plot.cca with optimize=TRUE and ordipointlabel in pipe #674

Merged
merged 26 commits into from
Aug 1, 2024

Conversation

jarioksa
Copy link
Contributor

@jarioksa jarioksa commented Jul 28, 2024

This is the second stage of new fully configurable plot.cca functions. This adds optimize = TRUE argument to text.ordiplot and hence to plot.cca as @gavinsimpson suggested in #657. With this, ordipointlabel was made usable in plot/ordiplot pipe. The usage of plotting text over non-transparent label was expanded to more functions with argument bg = <colour>, usually via ordilabel but directly implemented in ordipointlabel.

The real changes were made in base routines used by plot.cca:

  • ordipointlabel can be used in an ordiplot pipe and can draw text on labels with bg = <colour>. This optimizes any number of score types, although it defaults to two.
  • text.ordiplot gained new argument optimize = TRUE that will call ordipointlabel for one set of scores.
  • plot.cca only sanitizes its input and will call text.ordiplot for new features.
  • These changes also mean that the very same capabilities are available in pipe for text.ordiplot, ordilabel and ordipointlabel (and the two latter are more configurable in pipe than via plot.cca).

I made this as a PR instead of direct merge to allow comments and suggestions before merge, and to make these new capabilities more visible.

Arg 'add = TRUE' needs tweaking: points are currently drawn only
with 'add = FALSE'.
10% difference in graphic device dimensions  triggers message.
mar() is not checked, but it also influences plot size.
- try more times: now 64 (was 48) means that on average each
  position is tried 8 times (was 6).
- a bit more detailed and stronger penalty: now against moving
  towards origin and against corners.
Triggers false warnings if using args for scores(), for instance.
Function text.ordiplot gains arg 'optimize' to call ordipointlabel
to move text to reduce overlap, but put a point in the exact
location. Function plot.cca uses text.ordiplot and gains the same
ability. For instance, plot(cca(dune), spe.par = list(optimize=TRUE)).
This makes easier to have programmatic use of scores() when
input parameter can be a pre-processed matrix instead of a complex
list of matrices. Earlier ordipointabel(x, display=what) failed
in text.ordiplot() when called from plot.cca().
- global arg (dot argument) 'optimize = T' must be eval'ed to make
  it logical TRUE (will be symbol initially)
- add point defPointPar if pch not given by user
- message on arrows looking strange with optimize=TRUE
@jarioksa jarioksa merged commit 4d0eb85 into master Aug 1, 2024
7 checks passed
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.

1 participant