Skip to content

Commit

Permalink
Address position functionality
Browse files Browse the repository at this point in the history
Adds functionality to geom_text_lastonly. Note that built-in tools are likely to be more useful for most use cases.
  • Loading branch information
Daniel Comeaux authored and Daniel Comeaux committed Jan 2, 2024
1 parent 13563f0 commit 66bffc4
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions R/geom_text_lastonly.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
#' displayed as described in \code{?plotmath}.
#' @param nudge_x,nudge_y Horizontal and vertical adjustment to nudge labels by.
#' Useful for offsetting text from points, particularly on discrete scales.
#' Cannot be jointy specified with \code{position}.
#' Cannot be jointly specified with \code{position}.
#' @param position Position adjustment, either as a string, or the result of a
#' call to a position adjustment function. Cannot be jointy specified with
#' call to a position adjustment function. Cannot be jointly specified with
#' \code{nudge_x} or \code{nudge_y}.
#' @param check_overlap If \code{TRUE}, text that overlaps previous text in the
#' same layer will not be plotted. \code{check_overlap} happens at draw time
Expand Down Expand Up @@ -76,10 +76,18 @@ geom_text_lastonly <- function(mapping = NULL, data = NULL,
...
)
{
# Create a position function using specified nudge coordinates.
if (is.null(position)) {
position_lab <- position_nudge(nudge_x, nudge_y)
position_pt <- position_identity()
}
# Allow for a position override function, e.g., `position_jitter()`. Note that
# in most cases, it will be easier to manually adjust labels to preferred
# locations using the nudge functions.
else {
position_lab <- position
position_pt <- position_identity()
}

elements <- list(
if (add_points) {
Expand Down

0 comments on commit 66bffc4

Please sign in to comment.