使用该plot()
功能,是否可以在一定的时间间隔内更改线型(例如,从x=1
到x=2
),而将图的其余部分保留为另一种线型?
我知道我可以lines()
多次使用以达到相同的效果,但是我想知道是否有更简单的方法。
改用ggplot怎么样?
data <- data.frame(matrix(rnorm(20),20))
names(data) <- "series"
library(reshape2)
library(dplyr)
data <- data.frame(cbind(Index=1:nrow(data),data))
data$Col <- data$Index < 8 & data$Index > 3
ggplot(data, aes(x=Index,y=series,color=factor(Col))) +
geom_line(aes(group=1),size=1) +
guides(colour=F)
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句