xts图未显示在新设备/窗口中

问题描述

以下数据可以是tibbledata.table

  datetime                volume
  <dttm>                   <dbl>
  2020-08-25 09:30:00.000      0
  2020-08-25 09:30:12.000    107
  2020-08-25 09:30:50.000    221
  2020-08-25 09:30:50.000    132
  2020-08-25 09:30:50.000    148
  2020-08-25 09:30:50.000    100
  2020-08-25 09:30:50.000    100
  2020-08-25 09:30:58.000    100
  2020-08-25 09:31:56.000    157
  2020-08-25 09:32:36.000    288
  2020-08-25 09:32:36.000    100
  2020-08-25 09:33:10.000    235
  2020-08-25 09:33:23.000    182
  2020-08-25 09:33:44.000    218
  2020-08-25 09:33:44.000    179
  2020-08-25 09:34:18.000    318
  2020-08-25 09:34:27.000    101
  2020-08-25 09:34:27.000    157
  2020-08-25 09:34:27.000    200
  2020-08-25 09:34:27.000    114

我已将上述数据转换为xts对象,并希望从Rscript调用绘图功能作为命令行实用程序。

这是我将数据转换为xts的方式:

data %>% as.xts() -> testdata1

以上代码行的时间序列与以下内容不同:

data %>% as.xts() -> testdata2
identical(testdata1,testdata2)
# output: TRUE

因此,有两种方法可以解决此问题:

  # first option
  x11()  # linux calls x11()
  plot(x = data,observation.based = TRUE,major.ticks = "seconds",main = "Test Plot")
  prompt <- "press any key to close the plot"
  capture <- tcltk::tk_messageBox(message = prompt)
  
  # second option
  png("test.png")
  plot(x = data,main = "Test Plot")
  dev.off()
  browseURL("test.png)

以上两种方法均不适用于xts对象绘图。它适用于普通的data.framedata.tableggplot

有人尝试从命令行将xts绘制到新设备上吗?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)