Last data update: 2014.03.03

R: Dumbell charts
geom_dumbbellR Documentation

Dumbell charts

Description

The dumbbell geom is used to create dumbbell charts. Dumbbell dot plots–dot plots with two or more series of data–are an alternative to the clustered bar chart or slope graph.

Usage

geom_dumbbell(mapping = NULL, data = NULL, ..., point.colour.l = NULL,
  point.size.l = NULL, point.colour.r = NULL, point.size.r = NULL,
  na.rm = FALSE, show.legend = NA, inherit.aes = TRUE)

Arguments

mapping

Set of aesthetic mappings created by aes or aes_. If specified and inherit.aes = TRUE (the default), it is combined with the default mapping at the top level of the plot. You must supply mapping if there is no plot mapping.

data

The data to be displayed in this layer. There are three options:

If NULL, the default, the data is inherited from the plot data as specified in the call to ggplot.

A data.frame, or other object, will override the plot data. All objects will be fortified to produce a data frame. See fortify for which variables will be created.

A function will be called with a single argument, the plot data. The return value must be a data.frame., and will be used as the layer data.

...

other arguments passed on to layer. These are often aesthetics, used to set an aesthetic to a fixed value, like color = "red" or size = 3. They may also be parameters to the paired geom/stat.

point.colour.l

the colour of the left point

point.size.l

the size of the left point

point.colour.r

the colour of the right point

point.size.r

the size of the right point

na.rm

If FALSE (the default), removes missing values with a warning. If TRUE silently removes missing values.

show.legend

logical. Should this layer be included in the legends? NA, the default, includes if any aesthetics are mapped. FALSE never includes, and TRUE always includes.

inherit.aes

If FALSE, overrides the default aesthetics, rather than combining with them. This is most useful for helper functions that define both data and aesthetics and shouldn't inherit behaviour from the default plot specification, e.g. borders.

Aesthetics

Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("geom", "segment")}

Examples

df <- data.frame(trt=LETTERS[1:5],
                 l=c(20, 40, 10, 30, 50),
                 r=c(70, 50, 30, 60, 80))

ggplot(df, aes(y=trt, x=l, xend=r)) + geom_dumbbell()

ggplot(df, aes(y=trt, x=l, xend=r)) +
geom_dumbbell(color="#a3c4dc", size=0.75, point.colour.l="#0e668b")

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(SciencesPo)
Loading required package: ggplot2
initializing ... done

> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/SciencesPo/geom_dumbbell.Rd_%03d_medium.png", width=480, height=480)
> ### Name: geom_dumbbell
> ### Title: Dumbell charts
> ### Aliases: GeomDumbbell geom_dumbbell
> ### Keywords: datasets
> 
> ### ** Examples
> 
> df <- data.frame(trt=LETTERS[1:5],
+                  l=c(20, 40, 10, 30, 50),
+                  r=c(70, 50, 30, 60, 80))
> 
> ggplot(df, aes(y=trt, x=l, xend=r)) + geom_dumbbell()
> 
> ggplot(df, aes(y=trt, x=l, xend=r)) +
+ geom_dumbbell(color="#a3c4dc", size=0.75, point.colour.l="#0e668b")
> 
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>