0
私は4年間の時系列データを持っています。今私は、同じデータを年単位でプロットし、比較分析を行いたいと思います。ダミーデータは、私はそれが次の行ggplotを使って長い時系列データをプロットする
visualize_dataframe_all_columns(xts_df)
を使用して、すべてのシリーズをプロットするために時間がかかりすぎるggplot使用時には、上記の関数が定義されている、今のように
library(xts)
library(ggplot2)
timeindex <- seq(as.POSIXct('2016-01-01'),as.POSIXct('2016-12-31 23:59:59'), by = "1 mins")
dataframe <- data.frame(year1=rnorm(length(timeindex),100,10),year2=rnorm(length(timeindex),150,7),
year3=rnorm(length(timeindex),200,3),
year4=rnorm(length(timeindex),350,4))
xts_df <- xts(dataframe,timeindex)
あるとして:
visualize_dataframe_all_columns <- function(xts_data) {
library(RColorBrewer)# to increase no. of colors
library(plotly)
dframe <- data.frame(timeindex=index(xts_data),coredata(xts_data))
df_long <- reshape2::melt(dframe,id.vars = "timeindex")
colourCount = length(unique(df_long$variable))
getPalette = colorRampPalette(brewer.pal(8, "Dark2"))(colourCount) # brewer.pal(8, "Dark2") or brewer.pal(9, "Set1")
g <- ggplot(df_long,aes(timeindex,value,col=variable,group=variable))
g <- g + geom_line() + scale_colour_manual(values=getPalette)
ggplotly(g)
}
上記アプローチの問題点は次のとおりです。
- 作図するのに時間がかかります。プロット時間を短縮できますか?
plotly
を使用してプロットをズームするのは非常に難しいです。他にも良い方法がありますか?
このデータを視覚化する方法はありますか?