2016-11-22 40 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