2016-11-22 68 views
0

我有一个时间序列的大型数据集,我想用线条指示各个时间点的值。例如:根据密度绘制颜色重叠线

df.test=data.frame(runif(1000),runif(1000),runif(1000)*2,runif(1000)/2) 
matplot(t(df.test),type="l",col="black") 

我想做一些类似于smoothScatter来说明跨越的时间点线(例如,其中多个线重叠,则颜色将从黑色到红色变化)的重叠的密度,但是具有为此无法做任何事情。

有没有人知道的功能/包可以做到这一点或类似的东西?

在此先感谢!

回答

1

我认为你可以通过将alpha红色重叠为黑色来获得这样的效果。 (但我觉得输出一个字母的颜色,使凉)

set.seed(1); df.test = data.frame(runif(1000), runif(1000), runif(1000)*2, runif(1000)/2) 

matplot(t(df.test), type = "l", col = "black") 
matplot(t(df.test), type = "l", col = ggplot2::alpha("red", 0.1), add=T) 

matplot(t(df.test), type = "l", col = ggplot2::alpha("black", 0.2)) 

enter image description here enter image description here

+0

感谢您的回答,我认为它会工作不够好,我的需求。 – desc