【问题标题】:how to plot cluster of time-series in loop with different colors?如何用不同的颜色在循环中绘制时间序列簇?
【发布时间】:2014-05-26 13:09:13
【问题描述】:

我想知道,当我使用循环时,如何绘制具有不同颜色的时间序列簇。我知道程序ggplot() 会这样做,但我不能在循环之前使用它。代码如下:

plot(units_sold[,1], t="l", ylim=c(0,4500))

for (i in 2:126) { 
  if (klaster1[i,2] == "1")
    lines(units_sold[,i])
}

我应该在代码中的哪个位置添加以不同颜色绘制集群中每个时间序列的选项?

【问题讨论】:

标签: r plot time-series cluster-analysis


【解决方案1】:
plot(units_sold[,1], t="l", ylim=c(0,4500))

for (i in 2:126) 
 { 
   if (klaster1[i,2] == "1")
   lines(units_sold[,i], col = colors()[i])
  }

您可以使用一些调色板系统来改善颜色。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-03-24
    • 2016-07-27
    • 2013-02-20
    • 1970-01-01
    • 2018-04-04
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多