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

Address position functionality in geom_text_lastonly #159

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
4 changes: 2 additions & 2 deletions man/geom_text_lastonly.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.