R ggplot中的两行X轴标签

R ggplot中的两行X轴标签,r,ggplot2,label,R,Ggplot2,Label,我想在ggplot中制作两行X轴标签 在这个图中,我想在每个指定年份的下方再添加一行标签。差不多 1990 1995 2000 2005 2010 冷暖冷暖 这是我绘制这个图的代码 ggplot(subset(dat, countryid %in% c("1")), aes(date, nonpartisan))+geom_line(aes(color=countryid), color="dodgerblue1", size=1.4)+geom_line(aes(date, reshu

我想在ggplot中制作两行X轴标签

在这个图中,我想在每个指定年份的下方再添加一行标签。差不多

1990 1995 2000 2005 2010
冷暖冷暖

这是我绘制这个图的代码

ggplot(subset(dat, countryid %in% c("1")),  aes(date, 
nonpartisan))+geom_line(aes(color=countryid), color="dodgerblue1", 
size=1.4)+geom_line(aes(date, reshuffle), color="gray")+ theme_bw()
有没有办法通过专门为标签创建一列来多做一行标签


谢谢

您可以通过
scale\u x\u continuous
(或者
scale\u x\u date
,如果它实际上是
date
格式的话)添加自定义标签


可能重复的谢谢!这很好用。我只将您的代码从
scale\u x\u continuous
修改为
scale\u x\u date
。对中断也进行了一些小的修改。@user3077008您能发布生成的代码吗?谢谢
ggplot(subset(dat, countryid %in% c("1")),  aes(date, nonpartisan)) +
  geom_line(aes(color=countryid), color="dodgerblue1", size=1.4) +
  geom_line(aes(date, reshuffle), color="gray") + 
  theme_bw() +
  scale_x_continuous(name = 'date', 
                     breaks = c('1990', '1995', '2000', '2005', '2010'), 
                     labels = c('1990\ncold', '1995\nwarm', '2000\nwarm', '2005\ncold', '2010\nwarm'))