slopegraph: slopegraph

View source: R/slopegraph.R

slopegraphR Documentation

slopegraph

Description

slopegraph displays paired sample data as two sets of points connected by line segments as a visualization of overall trends. See also @leeper/slopegraph at GitHub.

Usage

slopegraph(
  x,
  y = NA,
  type = "b",
  names.arg = NA,
  xlab = NA,
  ylab = NA,
  colorize = F,
  pal = c("firebrick", "steelblue"),
  shim = 0.5,
  cex.text = 0.8,
  ...
)

Arguments

x:

numeric vector of values to plot on the left

y:

numeric vector of values to plot on the right

type:

'b' displays both points and lines; 'l' displays lines only. 't' replaces points with numeric values, as per Tufte.

names.arg:

optional names for labeling the x-axis

xlab:

label for x-axis, as in generic plot(). Defaults to 'Groups'.

ylab:

label for y-axis, as in generic plot(). Defaults to NA.

colorize:

use line colours to emphasize slope

pal:

vector of two colours for annotating slopes down and up, respectively.

shim:

width of horizontal padding to left and right of plot

cex.text:

character expansion for text

...:

additional arguments to pass to plot()

Examples

# CO2 emissions data
co2.emissions

# with default settings
slopegraph(co2.emissions)

# annotate slopes with colour
slopegraph(co2.emissions, names.arg=c(2000, 2010), 
ylab=expression(text=paste('CO'[2], ' emissions (metric tons) per capita')), 
type='b', cex.lab=1.2, colorize=T)

# more in style of Edward Tufte
slopegraph(co2.emissions, names.arg=c(2000, 2010), type='t')
title(expression(text=paste('CO'[2], ' emissions (metric tons) per capita')), 
family='Palatino')


ArtPoon/ggfree documentation built on July 11, 2024, 11:15 a.m.