看起来很简单,但我正在努力。基本上我试图可视化(绘制)每两秒钟出现的模拟流数据,即绘图实时连续。
我见过Microsoft Azure(但我没有昂贵的订阅)。我也看过动画包但它必须在渲染显示之前读入所有数据。有没有办法在R(或者python)中实现这一点? 这就是我到目前为止在R中所做的:
#simulate some sensor data
time <- seq(1,200,2)
sensor <- runif(100,1,100)
timedf <- data.frame(cbind(time,sensor))
timedf$time <- as.POSIXct(timedf$time,origin = "2016-05-05")
plot(timedf$time,timedf$sensor,type = "l")
#I want to visualize or plot the data continously every 2 seconds
#sleep function
mysleep <- function(x)
{
p1 <- proc.time()
Sys.sleep(x)
proc.time() - p1
}
for(i in 1:nrow(timedf)){
mysleep(2)
print(timedf[i,])
plot(timedf[i,]$time,timedf[i,]$sensor,type = "l")
par(new=FALSE)
}[![some sensor data][1]][1]
答案 0 :(得分:-1)
以下是使用nodejs
的演示:
#clone the nodejs plotly github directory
git clone https://github.com/plotly/plotly-nodejs.git
使用API credentials修改examples/config.json
文件,然后只需运行其中一个演示文稿(在此示例中为signal-stream.js
)
node signal-stream.js
将以以下形式输出JSON字符串:
{ streamstatus: 'All Streams Go!',
url: 'https://plot.ly/~voxnonecho/194',
message: '',
warning: '',
filename: 'streamSimpleSensor',
error: '' }
然后只需按照提供的网址进行操作: