Skip to content

Commit

Permalink
push text_repel change
Browse files Browse the repository at this point in the history
  • Loading branch information
sean-connelly-cmap committed Aug 13, 2024
1 parent c321d0f commit 9722173
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 25 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: cmapplot
Title: CMAP Themes and Color Palettes
Version: 1.2.1
Version: 1.2.2
Authors@R: c(
person("Daniel", "Comeaux",
role = c("aut", "cre"),
Expand Down
4 changes: 2 additions & 2 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export(GeomPointLast)
export(GeomRecessions)
export(GeomRecessionsText)
export(GeomTextLast)
export(GeomTextLastNew)
export(GeomTextLastRepel)
export(PositionNudgeRepel)
export(abbr_years)
export(apply_cmap_default_aes)
Expand All @@ -26,7 +26,7 @@ export(fetch_pal)
export(finalize_plot)
export(geom_recessions)
export(geom_text_lastonly)
export(geom_text_lastonly_new)
export(geom_text_lastonly_repel)
export(get_cmapplot_global)
export(get_cmapplot_globals)
export(gg_lwd_convert)
Expand Down
2 changes: 1 addition & 1 deletion R/cmapplot_globals.R
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ cmapplot_globals$geoms_that_change <- c(
"Line",
"Text",
"TextLast",
"TextLastNew",
"TextLastRepel",
"PointLast",
"RecessionsText"
)
Expand Down
2 changes: 1 addition & 1 deletion R/default_aes.R
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ init_cmap_default_aes <- function () {
size = cmapplot_globals$fsize$M/ggplot2::.pt, # pt-to-mm conversion
colour = cmapplot_globals$colors$blackish
),
TextLastNew = list(
TextLastRepel = list(
family = cmapplot_globals$font$strong$family,
fontface = ifelse(cmapplot_globals$font$strong$face == "bold", 2, 1),
size = cmapplot_globals$fsize$M/ggplot2::.pt, # pt-to-mm conversion
Expand Down
18 changes: 9 additions & 9 deletions R/geom_text_lastonly_new.R → R/geom_text_lastonly_repel.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#' Text (Last Only) New
#'
#' Label only the last point(s) on a plot. \code{geom_text_lastonly_new()} can be
#' Label only the last point(s) on a plot. \code{geom_text_lastonly_repel()} 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,18 +108,18 @@
#' labs(title="Random lines") +
#' scale_y_continuous("Percentage of absolutely nothing") +
#' scale_x_continuous("Year") +
#' geom_text_lastonly_new()
#' geom_text_lastonly_repel()
#'
#' # 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_new(add_points=TRUE, text_aes=list(fontface="bold"), point_aes=list(size=2.5))
#' geom_text_lastonly_repel(add_points=TRUE, text_aes=list(fontface="bold"), point_aes=list(size=2.5))
#'
#' @export
geom_text_lastonly_new <- function(mapping = NULL, data = NULL,
geom_text_lastonly_repel <- function(mapping = NULL, data = NULL,
stat = "identity", position = NULL,
parse = FALSE,
box.padding = 0.25,
Expand Down Expand Up @@ -176,7 +176,7 @@ geom_text_lastonly_new <- function(mapping = NULL, data = NULL,
data = data,
mapping = mapping,
stat = stat,
geom = GeomTextLastNew,
geom = GeomTextLastRepel,
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
GeomTextLastNew <- ggproto(
"GeomTextLastNew", Geom,
GeomTextLastRepel <- ggproto(
"GeomTextLastRepel", Geom,
required_aes = c("x", "y"),

default_aes = aes(
Expand Down Expand Up @@ -330,7 +330,7 @@ GeomTextLastNew <- ggproto(
data$hjust <- compute_just(data$hjust, data$x, data$y, data$angle)
}

ggname("geom_text_lastonly_new", gTree(
ggname("geom_text_lastonly_repel", gTree(
limits = limits,
data = data,
lab = data$label,
Expand Down Expand Up @@ -671,7 +671,7 @@ makeTextRepelGrobs <- function(
grobs
}

# GeomTextLastNew helper functions
# GeomTextLastRepel 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
6 changes: 3 additions & 3 deletions man/customproto.Rd

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

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

0 comments on commit 9722173

Please sign in to comment.