使用chart.TimeSeries时,为什么没有出现event.lines?

时间:2015-09-12 01:17:44

标签: r performanceanalytics

我正在尝试使用PerformanceAnalytics库中的chart.TimeSeries在一系列时间序列数据集上绘制各种事件。我试图效仿,但我想我错过了一些东西。 ExampleChart MyChart

我的垂直事件行和我的句号区域都没有显示在图表上。我的代码几乎与示例代码完全相同。有任何想法吗?

risk.dates = c(
  "2015-04-19"
  )
risk.labels = c(
  "Jon Oliver's Patent Episode "
  )

cycle.dates <- c ("2015-1-01/2015-01-31",
                      "2015-03-01/2015-03-31",
                      "2015-05-01/2015-05-31",
                      "2015-07-01/2015-07-31"
                      )
chart.TimeSeries(df, colorset = "darkblue",
                 date.format.in = "%Y-%m-%d",
                 legend.loc = NULL,
                 period.areas = cycles.dates,
                 period.color = "lightblue",
                 event.lines = risk.dates,
                 event.labels = risk.labels,
                 event.color = "red", lwd = 2,
                 main = "Reddit Sentiment Index",
                 auto.grid = FALSE)

df <- data.frame(DateTime=
          c("2/17/2015","2/18/2015","2/19/2015",
            "2/20/2015","2/21/2015","2/22/2015", 
            "2/23/2015","2/24/2015","2/25/2015",
            "2/26/2015","2/27/2015","2/28/2015",
            "2/28/2015","2/27/2015"),
           AvgSentimentScore=
             c("NA","NA","NA","NA","NA","NA","NA","NA","NA",
               "8.405975696","8.313470536","8.414560335",
                "8.720865075","9.284902246"))

0 个答案:

没有答案