Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Best technique for timelines

Now that Gaddafi's 40+ years rule has ended, I want to construct a timeline graph of his period in power with those of other countries over the era. e.g US presidents, German chancellors etc So the x axis would be time, the y axis countries and the timeline split - by the correct time frame - showing Nixon, Ford etc for the US

As I am trying to learn R, I would prefer a solution in that language but have a feeling it is not the best solution. Any suggestions for that or alternative, free solutions?

I should probably add that if in R the dataframe would start

Country  Boss   TookCharge

USA      Nixon   1969-01-20
USA      Ford    1974-08-09
Germany  Brandt  1969-10-22
Germany  Schmidt 1974-05-16
like image 377
pssguy Avatar asked Oct 21 '11 16:10

pssguy


People also ask

What is the best way to show timeline?

A common way to represent timeline is to use a series of repeat elements like chevrons or arrows. They are easy to create and easy to understand. You can enhance your message effectiveness with the following: Group each chevron with its corresponding explanation.


2 Answers

This is a simple task for ggplot:

Create some data:

x <- data.frame(
    country = rep(c("USA", "Germany"), each=2),
    boss = c("Nixon", "Ford", "Brandt", "Schmidt"),
    start = as.Date(c("1969-01-20", "1974-08-09", "1969-10-22", "1974-05-16"))
)

Make the plot:

library(ggplot2)
ggplot(x, aes(x=start, y=country)) + 
    geom_line() + 
    geom_point() + 
    geom_text(aes(label=boss), hjust=0, vjust=0) +
    xlim(c(min(x$start), max(x$start)+5*365)) # Add some space to right

enter image description here

like image 196
Andrie Avatar answered Sep 27 '22 22:09

Andrie


You could construct a set of sparse, irregular zoo or xts timeseries with one for each group of related events to annotate (US presidents in one, chancellors in another). The index column would be the date and the value would be the character annotation. You've then got your choice of charting libs. With Lattice you'd be able to split it into one panel per group.

Alternately you could just construct a single regular timeseries of the years he was in power with some bogus values for each data point. Plot that with a transparent line just to setup the base plot that you'd then add your annotations to. You could use abline or similar.

Another quicker way might be this http://www.inside-r.org/packages/cran/googleVis/docs/gvisAnnotatedTimeLine http://code.google.com/apis/chart/interactive/docs/gallery/annotatedtimeline.html#Example

like image 42
Tavis Rudd Avatar answered Sep 27 '22 21:09

Tavis Rudd