Skip to content

Commit

Permalink
sep geom v2
Browse files Browse the repository at this point in the history
  • Loading branch information
sean-connelly-cmap committed Aug 7, 2024
1 parent fb6993c commit a0e7fea
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions R/geom_text_lastonly_new.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#' Text (Last Only)
#' Text (Last Only) New
#'
#' Label only the last point(s) on a plot. \code{geom_text_lastonly()} can be
#' Label only the last point(s) on a plot. \code{geom_text_lastonly_new()} can be
#' used instead of \code{ggplot2::geom_text()} when only the last point(s)
#' should be labeled. This is accomplished by identifying the maximum value of
#' \code{x} in \code{data} and applying a filter to omit records where \code{x}
Expand Down Expand Up @@ -108,15 +108,15 @@
#' labs(title="Random lines") +
#' scale_y_continuous("Percentage of absolutely nothing") +
#' scale_x_continuous("Year") +
#' geom_text_lastonly()
#' geom_text_lastonly_new()
#'
#' # With points, label formatting and x-axis expansion
#' ggplot(df, aes(x=year, y=value, color=var, label=sprintf("%.1f%%", 100*value))) +
#' geom_line() +
#' labs(title="Random lines") +
#' scale_y_continuous("Percentage of absolutely nothing", labels=scales::percent) +
#' scale_x_continuous("Year", expand=expansion(mult=c(0.05, 0.10))) +
#' geom_text_lastonly(add_points=TRUE, text_aes=list(fontface="bold"), point_aes=list(size=2.5))
#' geom_text_lastonly_new(add_points=TRUE, text_aes=list(fontface="bold"), point_aes=list(size=2.5))
#'
#' @export
geom_text_lastonly_new <- function(mapping = NULL, data = NULL,
Expand Down Expand Up @@ -176,7 +176,7 @@ geom_text_lastonly_new <- function(mapping = NULL, data = NULL,
data = data,
mapping = mapping,
stat = stat,
geom = GeomTextLast,
geom = GeomTextLastNew,
position = position_lab,
show.legend = show.legend,
inherit.aes = inherit.aes,
Expand Down Expand Up @@ -224,8 +224,8 @@ NULL
#' @format NULL
#' @usage NULL
#' @export
GeomTextLast <- ggproto(
"GeomTextLast", Geom,
GeomTextLastNew <- ggproto(
"GeomTextLastNew", Geom,
required_aes = c("x", "y"),

default_aes = aes(
Expand Down Expand Up @@ -345,7 +345,7 @@ GeomTextLast <- ggproto(
direction = direction,
seed = seed,
verbose = verbose,
cl = "textrepeltree"
cl = "textlastrepel"
))
},

Expand All @@ -356,7 +356,7 @@ GeomTextLast <- ggproto(
#' @param x A grid grobTree.
#' @export
#' @noRd
makeContent.textrepeltree <- function(x) {
makeContent.textlastrepel <- function(x) {

# The padding around each bounding box.
box_padding_x <- convertWidth(x$box.padding, "native", valueOnly = TRUE)
Expand Down Expand Up @@ -668,7 +668,7 @@ makeTextRepelGrobs <- function(
grobs
}

# GeomTextLast helper functions
# GeomTextLastNew helper functions
# copied from ggplot2
compute_just <- function(just, a, b = a, angle = 0) {
# As justification direction is relative to the text, not the plotting area
Expand Down

0 comments on commit a0e7fea

Please sign in to comment.