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

Make the segment the same color as the text #29

Merged
merged 1 commit into from Mar 15, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 10 additions & 9 deletions R/geom-text-repel.R
Expand Up @@ -67,9 +67,9 @@
#' \code{unit(0.25, "lines")}.
#' @param point.padding Amount of padding around labeled point. Defaults to
#' \code{unit(0, "lines")}.
#' @param segment.color Color of the line segment connecting the data point to
#' the text labe. Defaults to \code{#666666}.
#' @param segment.size Width of segment, in mm.
#' @param segment.size Width of line segment connecting the data point to
#' the text label, in mm.
#' @param segment.alpha Transparency of the segment, in \code{[0,1]}. Makes segments half transparent by default.
#' @param arrow specification for arrow heads, as created by \code{\link[grid]{arrow}}
#' @param force Force of repulsion between overlapping text labels. Defaults
#' to 1.
Expand Down Expand Up @@ -124,8 +124,8 @@ geom_text_repel <- function(
...,
box.padding = unit(0.25, "lines"),
point.padding = unit(1e-6, "lines"),
segment.color = "#666666",
segment.size = 0.5,
segment.alpha = 0.5,
arrow = NULL,
force = 1,
max.iter = 2000,
Expand All @@ -148,8 +148,8 @@ geom_text_repel <- function(
na.rm = na.rm,
box.padding = box.padding,
point.padding = point.padding,
segment.color = segment.color,
segment.size = segment.size,
segment.alpha = segment.alpha,
arrow = arrow,
force = force,
max.iter = max.iter,
Expand All @@ -170,7 +170,7 @@ GeomTextRepel <- ggproto("GeomTextRepel", Geom,

default_aes = aes(
colour = "black", size = 3.88, angle = 0,
alpha = NA, family = "", fontface = 1, lineheight = 1.2
alpha = 1, family = "", fontface = 1, lineheight = 1.2
),

draw_panel = function(
Expand All @@ -179,8 +179,8 @@ GeomTextRepel <- ggproto("GeomTextRepel", Geom,
na.rm = FALSE,
box.padding = unit(0.25, "lines"),
point.padding = unit(1e-6, "lines"),
segment.color = "#666666",
segment.size = 0.5,
segment.alpha = 0.5,
arrow = NULL,
force = 1,
max.iter = 2000,
Expand Down Expand Up @@ -218,8 +218,8 @@ GeomTextRepel <- ggproto("GeomTextRepel", Geom,
nudges = nudges,
box.padding = box.padding,
point.padding = point.padding,
segment.color = segment.color,
segment.size = segment.size,
segment.alpha = segment.alpha,
arrow = arrow,
force = force,
max.iter = max.iter,
Expand Down Expand Up @@ -282,6 +282,7 @@ makeContent.textrepeltree <- function(x) {

grobs <- lapply(1:nrow(x$data), function(i) {
row <- x$data[i, , drop = FALSE]
# browser()
textRepelGrob(
x$lab[i],
x = unit(repel$x[i], "native"),
Expand All @@ -298,7 +299,7 @@ makeContent.textrepeltree <- function(x) {
lineheight = row$lineheight
),
segment.gp = gpar(
col = scales::alpha(x$segment.color, row$alpha),
col = scales::alpha(row$colour, row$alpha * x$segment.alpha),
lwd = x$segment.size * .pt
),
arrow = x$arrow
Expand Down
12 changes: 6 additions & 6 deletions man/geom_text_repel.Rd

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