Skip to content

Commit

Permalink
Merge pull request #31 from mps9506/labelArguments
Browse files Browse the repository at this point in the history
ggslopegraph2 arguments format text labels
  • Loading branch information
ibecav committed Aug 7, 2018
2 parents 6aae392 + 1b1d48d commit de7aebd
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 5 deletions.
20 changes: 16 additions & 4 deletions R/ggslopegraph2.R
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@
#' "Others" = "gray", "PC" = "blue"). Any input must be character, and the length
#' of a vector \bold{should} equal the number of levels in \code{Grouping}. If the
#' user does not provide enough colors they will be recycled.
#' @param datatextfamily Optionally the font family of the plotted data points. datatextfamily = "sans" is the default.
#' @param datatextface Optionally the font face of the plotted data points. datatextface = "plain" is the default.
#' @param labeltextfamily Optionally the font family of the grouping labels. labeltextfamily = "sans" is the default.
#' @param labeltextface Optionally the font face of the grouping labels. labeltextface = "bold" is the default.
#'
#' @return A \code{\link[ggplot2]{ggplot}} object.
#' @author Chuck Powell
Expand Down Expand Up @@ -87,7 +91,11 @@ ggslopegraph2 <-
captiontextsize = 8,
linethickness = 1,
linecolor = "ByGroup",
datatextsize = 2.5
datatextsize = 2.5,
datatextfamily = "sans",
datatextface = "plain",
labeltextfamily = "sans",
labeltextface = "bold"
) {
# Since ggplot2 objects are just regular R objects, put them in a list
my_special <- list(
Expand Down Expand Up @@ -173,18 +181,22 @@ ggslopegraph2 <-
geom_text_repel(data = dataframe %>% filter(!! times == min(!! times)),
aes_(label = grouping) ,
hjust = "left",
fontface = "bold",
fontface = labeltextface,
family = labeltextfamily,
size = ytextsize,
nudge_x = -.45,
direction = "y") +
geom_text_repel(data = dataframe %>% filter(!! times == max(!! times)),
aes_(label = grouping),
hjust = "right",
fontface = "bold",
fontface = labeltextface,
family = labeltextfamily,
size = ytextsize,
nudge_x = .5,
direction = "y") +
geom_label(aes_(label = measurement), size = datatextsize, label.padding = unit(0.05, "lines"), label.size = 0.0) +
geom_label(aes_(label = measurement), size = datatextsize,
label.padding = unit(0.05, "lines"), label.size = 0.0,
fontface = datatextface, family = datatextfamily) +
my_special +
labs(
title = title,
Expand Down
12 changes: 11 additions & 1 deletion man/ggslopegraph2.Rd

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

0 comments on commit de7aebd

Please sign in to comment.