Description Usage Arguments Value Author(s) References See Also Examples
Convert an R data frame (containing a panel dataset, where rows are observations and columns are time periods) into an Edward Tufte-inspired Slopegraph.
1 2 3 4 5 6 7 8 9 10 11 | slopegraph(data, main = NULL, xlab = "", ylab = "",
xlabels = names(data), xlim = c(0.5, ncol(data) + 0.5),
ylim = c(min(data, na.rm = TRUE) - diff(range(data, na.rm = TRUE))/100,
max(data, na.rm = TRUE) + diff(range(data, na.rm = TRUE))/100), bty = "n",
xaxt = "n", yaxt = "n", panel.first = NULL, panel.last = NULL,
labpos.left = 2, labpos.right = 4, leftlabels = NULL,
rightlabels = NULL, decimals = 0L, col.lines = par("fg"),
col.lab = col.lines, col.num = col.lines, col.xaxt = par("fg"),
offset.x = NULL, offset.lab = 0.1, cex.lab = 1, cex.num = 1,
family = "serif", font.lab = 1, font.num = 1, lty = par("lty"),
lwd = par("lwd"), mai = NULL, na.span = FALSE, ...)
|
data |
An observation-by-period data.frame, with at least two columns. Missing values are allowed. |
main |
The main title of the plot. Default is |
xlab |
The x-axis label for the plot. Default is |
ylab |
The y-axis label for the plot. Default is |
xlabels |
The labels to use for the slopegraph periods. Default is |
xlim |
The x-axis limits of the plot. Automatically calculated by default. |
ylim |
The y-axis limits of the plot. Automatically calculated by default. |
bty |
The box type for the plot. Default is |
xaxt |
The x-axis type for the plot. Default is |
yaxt |
The y-axis type for the plot. Default is |
panel.first |
An expression to add something between drawing the blank canvas and adding the plot content (i.e., behind the slopegraph). Default is |
panel.last |
An expression to add something after adding the plot content. Default is |
labpos.left |
The |
labpos.right |
The |
leftlabels |
The parameter for the rightside observation labels. Default is using row indexes. |
rightlabels |
The parameter for the rightside observation labels. Default is using row indexes. |
decimals |
The number of decimals to display for values in the plot. Default is |
col.lines |
A vector of colors for the slopegraph lines. Default is |
col.lab |
A vector of colors for the observation labels. Default is |
col.num |
A vector of colors for the number values. Default is |
col.xaxt |
A character string containing the x-axis color. Default is |
offset.x |
A small offset for |
offset.lab |
A small offset for the observation labels. Default is |
cex.lab |
A numeric value indicating the size of row labels. Default is |
cex.num |
A numeric value indicating the size of numeric labels. Default is |
family |
The font family to use in the plots. Set to “serif” by default. |
font.lab |
Default is |
font.num |
Default is |
lty |
A vector of line type values for the slopegraph lines. Default is |
lwd |
A vector of line width values for the slopegraph lines. Default is |
mai |
A margin specification. Default is |
na.span |
A logical indicating whether line segments should span periods with missing values. The default is |
... |
Additional arguments to |
A five-variable data frame, where each row contains: the row number from data
, x1, x2, y1, and y2 coordinates for each drawn segment, invisibly.
Thomas J. Leeper
http://www.edwardtufte.com/bboard/q-and-a-fetch-msg?msg_id=0003nk
Tufte, Edward. The Visual Display of Quantitative Information. Graphics Press.
Tufte, Edward. Beautiful Evidence. Graphics Press.
cancer
, gdp
, states
For a ggplot2 version, use ggslopegraph
.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | ## Tufte's Cancer Graph (to the correct scale)
data(cancer)
slopegraph(cancer, col.lines = 'gray', xlim = c(-.5,5.5),
xlabels = c('5 Year','10 Year','15 Year','20 Year'))
## Tufte's GDP Graph
data(gdp)
slopegraph(gdp, col.line='gray', xlabels = c('1970','1979'),
main = 'Current Receipts of Goverment as a Percentage of Gross Domestic Product')
## Ranking of U.S. State populations
data(states)
slopegraph(states, col.line='black', ylim = c(38,0),
main = 'Relative Rank of U.S. State Populations, 1790-1870')
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.