Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

added fatten parameter to geom_pointrange

  • Loading branch information...
commit 6b96a3b083132c3a483493e6aea64711f5551b94 1 parent 24fbbc3
Jeffrey Arnold authored

Showing 2 changed files with 18 additions and 10 deletions. Show diff stats Hide diff stats

  1. +13 9 R/geom-pointrange.r
  2. +5 1 man/geom_pointrange.Rd
22 R/geom-pointrange.r
... ... @@ -1,9 +1,10 @@
1 1 #' An interval represented by a vertical line, with a point in the middle.
2   -#'
3   -#' @section Aesthetics:
  2 +#'
  3 +#' @section Aesthetics:
4 4 #' \Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("geom", "pointrange")}
5 5 #'
6 6 #' @inheritParams geom_point
  7 +#' @param fatten a multiplicative factor to fatten the point by
7 8 #' @seealso
8 9 #' \code{\link{geom_errorbar}} for error bars,
9 10 #' \code{\link{geom_linerange}} for range indicated by straight line, + examples,
@@ -13,33 +14,36 @@
13 14 #' @export
14 15 #' @examples
15 16 #' # See geom_linerange for examples
16   -geom_pointrange <- function (mapping = NULL, data = NULL, stat = "identity", position = "identity", ...) {
17   - GeomPointrange$new(mapping = mapping, data = data, stat = stat, position = position, ...)
  17 +geom_pointrange <- function (mapping = NULL, data = NULL, stat = "identity",
  18 + position = "identity", fatten=4, ...) {
  19 + GeomPointrange$new(mapping = mapping, data = data, stat = stat,
  20 + position = position, fatten=fatten, ...)
18 21 }
19 22
20 23 GeomPointrange <- proto(Geom, {
21 24 objname <- "pointrange"
22 25
23 26 default_stat <- function(.) StatIdentity
24   - default_aes <- function(.) aes(colour = "black", size=0.5, linetype=1, shape=16, fill=NA, alpha = NA)
  27 + default_aes <- function(.) aes(colour = "black", size=0.5, linetype=1,
  28 + shape=16, fill=NA, alpha = NA)
25 29 guide_geom <- function(.) "pointrange"
26 30 required_aes <- c("x", "y", "ymin", "ymax")
27 31
28   - draw <- function(., data, scales, coordinates, ...) {
  32 + draw <- function(., data, scales, coordinates, ..., fatten=4) {
29 33 if (is.null(data$y)) return(GeomLinerange$draw(data, scales, coordinates, ...))
30 34 ggname(.$my_name(),gTree(children=gList(
31 35 GeomLinerange$draw(data, scales, coordinates, ...),
32   - GeomPoint$draw(transform(data, size = size * 4), scales, coordinates, ...)
  36 + GeomPoint$draw(transform(data, size = size * fatten), scales, coordinates, ...)
33 37 )))
34 38 }
35 39
36 40 draw_legend <- function(., data, ...) {
37 41 data <- aesdefaults(data, .$default_aes(), list(...))
38   -
  42 +
39 43 grobTree(
40 44 GeomPath$draw_legend(data, ...),
41 45 GeomPoint$draw_legend(transform(data, size = size * 4), ...)
42 46 )
43 47 }
44   -
  48 +
45 49 })
6 man/geom_pointrange.Rd
@@ -3,9 +3,13 @@
3 3 \title{An interval represented by a vertical line, with a point in the middle.}
4 4 \usage{
5 5 geom_pointrange(mapping = NULL, data = NULL,
6   - stat = "identity", position = "identity", ...)
  6 + stat = "identity", position = "identity", fatten = 4,
  7 + ...)
7 8 }
8 9 \arguments{
  10 + \item{fatten}{a multiplicative factor to fatten the point
  11 + by}
  12 +
9 13 \item{mapping}{The aesthetic mapping, usually constructed
10 14 with \code{\link{aes}} or \code{\link{aes_string}}. Only
11 15 needs to be set at the layer level if you are overriding

0 comments on commit 6b96a3b

Please sign in to comment.
Something went wrong with that request. Please try again.