答:
我了解了下你的这个代码,看需求应该是替换掉原本的x轴标签,你用的这个“scale_x_continuous”方法报错提示应替换标签数目与绘制的x轴标签刻度数不匹配的。
对于标签替换,我提供下我的处理思路:

这是我用于绘图的数据data.plot,数据表有4列,以下是这四列的属性:
> str(data.plot)
'data.frame': 38 obs. of 4 variables:
$ phaselabel : Factor w/ 43 levels "phase_1977","phase_1978",..: 1 1 1 1 2 2 2 2 3 3 ...
$ time_series: int 1 1 1 1 2 2 2 2 3 3 ...
$ sample : chr "Action" "Adventure" "Comedy" "Drama" ...
$ value : num 2.984 0.209 0.516 2.54 1.915 ...
其中,第一列phaselabel 是用于更改的x轴标签,属性为字符串;第二列time_series是用于绘制geom_stream()x轴提供的时间序列,是一个数值型序列;第三列sample 是样本;第四列是每个时间点上每个样本的值,属性为数值型序列。
这是绘图函数:
ggplot(data.plot,aes(x = time_series,y = value,fill=sample)) + geom_stream() +
scale_x_continuous(breaks = seq(1,max(data.plot$time_series)),labels = unique(data.plot$phaselabel)) #调整x轴的刻度标签,按一个单位分隔开来,每个单位的刻度替换为unique(data.plot$phaselabel)中的标签
出图结果
