时间表的最佳技术 [英] Best technique for timelines

查看:74
本文介绍了时间表的最佳技术的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

现在,卡扎菲40多年的统治时代已经结束,我想建立一个时间表,说明他与该时代其他国家的执政时期.例如美国总统,德国总理等 因此,x轴为时间,y轴为国家,时间轴按正确的时间范围划分-显示美国的尼克松,福特等

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

在尝试学习R时,我更喜欢用该语言的解决方案,但感觉这不是最好的解决方案.有什么建议或其他免费解决方案吗?

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?

我可能应该补充一点,如果在R中数据帧将开始

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

推荐答案

这是ggplot的简单任务:

创建一些数据:

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"))
)

绘制情节:

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

这篇关于时间表的最佳技术的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆