slopegraph | R Documentation |
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.
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,
...
)
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 |
ylab: |
label for y-axis, as in generic |
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 |
# 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')
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.