Draw a chronological timeline with ggplot2

前端 未结 4 971
小蘑菇
小蘑菇 2020-12-07 23:23

I have data like

data = as.data.frame(  rbind(   c(\"1492\", \"Columbus sailed the ocean blue\"),
                                c(\"1976\", \"Americans lis         


        
4条回答
  •  我在风中等你
    2020-12-08 00:08

    This seems like a better job for R's base graphics (really, this kind of thing probably better fits with a tool like Illustrator or something of that ilk).

    dat = as.data.frame(rbind(c("1492", "Columbus sailed the ocean blue"),
                           c("1976", "Americans listened to Styx"),
                           c("2008", "Financial meltdown")))
    dat$V1 <- as.Date(dat$V1,"%Y")
    dat$val <- c(-1,1,-0.5)
    
    plot(dat$V1,dislocations, type = "n",xaxt = "n",bty = "n", 
         xlab = "Time", ylab = "Dislocations")
    u <- par("usr")
    arrows(u[1], 0, u[2], 0, xpd = TRUE)
    points(dat$V1,dat$val,pch = 20)
    segments(dat$V1,c(0,0,0),dat$V1,dat$val)
    text(x=dat$V1,y=dat$val,labels=dat$V2,pos=c(4,2,2))
    

    produces something like this:

    enter image description here

提交回复
热议问题