Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/67.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R xts绘图未显示在新设备/窗口中_R_Plot_Time Series_Xts - Fatal编程技术网

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

R xts绘图未显示在新设备/窗口中,r,plot,time-series,xts,R,Plot,Time Series,Xts,以下数据可以是TIBLE或数据。表: 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

以下数据可以是
TIBLE
数据。表

  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
上述代码行的时间序列与以下时间序列不同:

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, 
       observation.based = TRUE, 
       major.ticks = "seconds", 
       main = "Test Plot")
  dev.off()
  browseURL("test.png)
#第一个选项
x11()#linux调用x11()
绘图(x=数据,
observation.based=TRUE,
major.ticks=“秒”,
main=“测试图”)

提示使用以下示例的两种绘图方法:
数据(AirPassenger);xts1@astrofunkswag不确定这是否正确;我也是
as.xts
;更重要的是,
AirPassengers
的分辨率与我的不同,即我的是以秒为单位的不规则时间序列,
AirPassengers
是等距的年度数据;如果你能用我的示例数据重现绘图,那肯定意味着我的绘图方式有问题。但是,是的,我应该添加如何转换数据。不过,解决方案可能是个问题。我只是尝试了等距离的小时数据;这对我也不起作用。
  # 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, 
       observation.based = TRUE, 
       major.ticks = "seconds", 
       main = "Test Plot")
  dev.off()
  browseURL("test.png)