Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Add geom_central #685

Closed
wants to merge 1 commit into from

2 participants

Jim Hester Hadley Wickham
Jim Hester

Adds a new geom_central geom, fixes #250

Jim Hester jimhester Add geom_central
Adds a new geom_central geom, fixes #250
96f4ecd
Hadley Wickham
Owner

Could you please rebase/merge against master, re-document with the development version of roxygen2 (install_github("klutometis/roxygen) and resubmit?

Hadley Wickham hadley closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Oct 10, 2012
  1. Jim Hester

    Add geom_central

    jimhester authored
    Adds a new geom_central geom, fixes #250
This page is out of date. Refresh to see the latest.
Showing with 43 additions and 0 deletions.
  1. +1 −0  DESCRIPTION
  2. +42 −0 R/geom-central.r
1  DESCRIPTION
View
@@ -76,6 +76,7 @@ Collate:
'geom-bin2d.r'
'geom-blank.r'
'geom-boxplot.r'
+ 'geom-central.r'
'geom-crossbar.r'
'geom-defaults.r'
'geom-dotplot.r'
42 R/geom-central.r
View
@@ -0,0 +1,42 @@
+#' Middle indicated by horizontal line. A \code{\link{geom_crossbar}} without
+#' the .
+#'
+#' @section Aesthetics:
+#' \Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("geom", "central")}
+#'
+#' @inheritParams geom_point
+#' @param fatten a multiplicate factor to fatten middle line by
+#' @seealso \code{\link{geom_errorbar}} for error bars,
+#' \code{\link{geom_pointrange}} and \code{\link{geom_linerange}} for other
+#' ways of showing mean + error, \code{\link{stat_summary}} to compute
+#' errors from the data, \code{\link{geom_smooth}} for the continuous analog.
+#' @export
+#' @examples
+#' # See geom_linerange for examples
+geom_central <- function (mapping = NULL, data = NULL, stat = "identity", position = "identity",
+fatten = 2, ...) {
+ GeomCentral$new(mapping = mapping, data = data, stat = stat,
+ position = position, fatten = fatten, ...)
+}
+
+GeomCentral <- proto(Geom, {
+ objname <- "central"
+
+ reparameterise <- function(., df, params) {
+ GeomErrorbar$reparameterise(df, params)
+ }
+
+ default_stat <- function(.) StatIdentity
+ default_pos <- function(.) PositionIdentity
+ default_aes = function(.) aes(colour="black", fill=NA, size=0.5, linetype=1, alpha = NA)
+ required_aes <- c("x", "y")
+ guide_geom <- function(.) "path"
+
+ draw <- function(., data, scales, coordinates, fatten = 2, width = NULL, ...) {
+ middle <- transform(data, x = xmin, xend = xmax, yend = y, size = size * fatten, alpha = NA)
+
+ ggname(.$my_name(), gTree(children=gList(
+ GeomSegment$draw(middle, scales, coordinates, ...)
+ )))
+ }
+})
Something went wrong with that request. Please try again.