Skip to content

Commit

Permalink
position argument added and geom_segment replaced by geom_linerange #45
Browse files Browse the repository at this point in the history
  • Loading branch information
kassambara committed Oct 30, 2017
1 parent e239c05 commit 5ede873
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
17 changes: 13 additions & 4 deletions R/ggdotchart.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ NULL
#' order. Allowed values are one of "descending" and "ascending". Partial
#' match are allowed (e.g. sorting = "desc" or "asc"). Default is
#' "descending".
#' @param x.text.col logical. If TRUE (default), x axis texts are colored by groups.
#' @param x.text.col logical. If TRUE (default), x axis texts are colored by
#' groups.
#' @param position Position adjustment, either as a string, or the result of a
#' call to a position adjustment function.
#' @param ... other arguments to be passed to \code{\link[ggplot2]{geom_point}}
#' and \code{\link{ggpar}}.
#' @details The plot can be easily customized using the function ggpar(). Read
Expand Down Expand Up @@ -63,6 +66,7 @@ ggdotchart <- function(data, x, y, group = NULL,
select = NULL, remove = NULL, order = NULL,
label = NULL, font.label = list(size = 11, color = "black"),
label.select = NULL, repel = FALSE, label.rectangle = FALSE,
position = "identity",
ggtheme = theme_pubr(),
...){

Expand All @@ -78,7 +82,8 @@ ggdotchart <- function(data, x, y, group = NULL,
select = select , remove = remove, order = order,
add = add, add.params = add.params,
label = label, font.label = font.label, label.select = label.select,
repel = repel, label.rectangle = label.rectangle, ggtheme = ggtheme, ...)
repel = repel, label.rectangle = label.rectangle,
position = position, ggtheme = ggtheme, ...)

# User options
#:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
Expand Down Expand Up @@ -152,9 +157,13 @@ ggdotchart_core <- function(data, x, y, group = NULL,
size = size, position = position)

mapping <- seg.opts$mapping %>%
.add_item(y = 0, x = x, yend = y, xend = x)
.add_item(x = x, ymin = 0, ymax = y)
option <- seg.opts$option

# mapping <- seg.opts$mapping %>%
# .add_item(y = 0, x = x, yend = y, xend = x)
# option <- seg.opts$option

seg.col <- "lightgray"
if(!is.null(add.params$color))
seg.col <- add.params$color
Expand All @@ -175,7 +184,7 @@ ggdotchart_core <- function(data, x, y, group = NULL,
# option$size <- add.params$size

option[["mapping"]] <- do.call(aes_string, mapping)
p <- p + do.call(geom_segment, option)
p <- p + do.call(geom_linerange, option)
}


Expand Down
8 changes: 6 additions & 2 deletions man/ggdotchart.Rd

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

0 comments on commit 5ede873

Please sign in to comment.