首页 \ 问答 \ 在R中实时自动递增ggplot(Real-time auto incrementing ggplot in R)

在R中实时自动递增ggplot(Real-time auto incrementing ggplot in R)

该主题回答了如何在R中创建具有实时效果的增量图。

我想用ggplot2代替R的基本plot做同样的事情。 直接从该链接的答案中复制,我尝试了这个,但它不起作用:

n=1000
df=data.frame(time=1:n,y=runif(n))
window=100
for(i in 1:(n-window)) {
  print(i)
  flush.console()
  ggplot(df) + geom_line(aes(x=time, y=y), size=0.7) + xlim(i,i+window)
  Sys.sleep(.09)
}

我猜ggplot2的图像渲染效果不同。 是否可以使用ggplot2创建实时更新效果?

理想情况下,我希望能够显示多个geom_line 。 但我猜逻辑将是一样的。

此外,当R-Studio中的情节是“缩放”时,是否可以实现此目的?


This thread answers how to create incremental plots in R with a real-time effect.

I want to do the same thing with ggplot2 instead of R's base plot. Directly copying from the answer in that link, I tried this but it didn't work:

n=1000
df=data.frame(time=1:n,y=runif(n))
window=100
for(i in 1:(n-window)) {
  print(i)
  flush.console()
  ggplot(df) + geom_line(aes(x=time, y=y), size=0.7) + xlim(i,i+window)
  Sys.sleep(.09)
}

I guess the image rendering for ggplot2 works differently. Is it possible to create a real-time updating effect with ggplot2?

Ideally, I want to be able to display multiple geom_lines. But I guess the logic will be the same.

Also, is it possible to achieve this when the plot is "Zoom"ed in in R-Studio?


原文:https://stackoverflow.com/questions/27205610
更新时间:2023-04-11 10:04

最满意答案

对象属性是这样设置的:

var obj = {
  foo: "foo", //':' instead of '=' and ',' not ';'
  bar: "bar"    
};

如果您想稍后设置属性:

obj.test = "test";
obj["test"] = "test";

var test = "test";
obj[test] = test; //Using a variable value as property

不是这样的:

var obj = {
  obj.foo: "foo" //syntax error
};

这是你的代码修复:

podToSave.address = {
    //number not address.number
    number: pod.address.number, //= and ; changed
    lineOne: pod.address.lineOne,
    lineTwo: pod.address.lineTwo,
    postcode: pod.address.postcode
  };
  podToSave.phoneNumbers = {
    mobile: pod.phoneNumbers.mobile,
    landline: pod.phoneNumbers.landline
  }

Object properties are set this way:

var obj = {
  foo: "foo", //':' instead of '=' and ',' not ';'
  bar: "bar"    
};

If you want to set a property later on:

obj.test = "test";
obj["test"] = "test";

var test = "test";
obj[test] = test; //Using a variable value as property

But not like this:

var obj = {
  obj.foo: "foo" //syntax error
};

Here's your code fixed:

podToSave.address = {
    //number not address.number
    number: pod.address.number, //= and ; changed
    lineOne: pod.address.lineOne,
    lineTwo: pod.address.lineTwo,
    postcode: pod.address.postcode
  };
  podToSave.phoneNumbers = {
    mobile: pod.phoneNumbers.mobile,
    landline: pod.phoneNumbers.landline
  }

相关问答

更多
  • 从8开始的Internet Explorer版本有一个内置的调试器,类似于Firebug - 按F12启动它(默认情况下)。 标准错误报告很糟糕,但调试器会为您提供有关错误发生位置的更准确的反馈。 (我的看法是标准的Javascript错误处理假设你是一个典型的IE用户并且给你很少的反馈。启动开发工具让它知道你可以处理真相。) It was the response from AJAX after all. IE had problems sending all the GET parameters res ...
  • 如果这是Python 3,那么print函数现在需要括号。 尝试print("test") 。 (编辑:如果Python继续让你想吃键盘, 这可能会有所帮助 。) If this is Python 3, then the print function now requires parenthesis. Try print("test"). (EDIT: If Python continues to make you want to eat your keyboard, this might help.)
  • 这将有效: $sql = "SELECT * FROM `image_upload` where uid='$uid' "; This will work: $sql = "SELECT * FROM `image_upload` where uid='$uid' ";
  • 改变这个: print(uppercasecount),(lowercasecount),(digitcount) 至: print uppercasecount,lowercasecount,digitcount 而不是readlines ,使用read : for character in infile.read(): readlines将整个文件读作一个行列表 read会将整个文件作为字符串读取 change this: print(uppercasecount),(lowercasecount ...
  • Desc是一个关键字。 更改为: [Desc] 。 SQL中的所有关键字 : https : //www.drupal.org/docs/develop/coding-standards/list-of-sql-reserved-words Desc is a keyword. Change to this: [Desc]. All Keywords in SQL: https://www.drupal.org/docs/develop/coding-standards/list-of-sql-reserv ...
  • 但是,现在编写语句的方式将起作用(一旦将列引用添加到case语句,正如其他文章所述),但是,让其余语法不加注释将会对其他人的情况造成损害。 虽然你可能只需要运行这个查询一次,但我和其他人遇到类似的情况,即多行Update也依赖于离我们源数据3或4个表的数据,并且必须多次运行(比如在报告中) 。 通过将你的子选择合并成单个select语句并将结果保存到#Temp表或一个@Table变量中,你只需要执行一次查找,然后从结果集中选择更新。 以下是使用@table变量的示例: declare @OilStatus ...
  • 您的查询仅在存储过程/函数上下文中有效。 在那里参考。 Your query is only valid in a stored procedure/function context. See there for reference.
  • 其他人已经指出错误是由对齐错误引起的,您可以通过将first , second , third和fourth与words对齐来修复 - 即将它们向右移动两列。 除此之外,我想指出两件事: words不是一个非常幸运的名字,因为它是Prelude中标准库函数的名称。 通过注意你的代码 - 对于长度为4的字节toIntegral - 解包字节toIntegral ,然后在每个元素上调用toIntegral然后使用(.|.)折叠列表,你可以完全离开。 即我认为你也可以做类似的事情 bs2int' :: B.Byt ...
  • 对象属性是这样设置的: var obj = { foo: "foo", //':' instead of '=' and ',' not ';' bar: "bar" }; 如果您想稍后设置属性: obj.test = "test"; obj["test"] = "test"; var test = "test"; obj[test] = test; //Using a variable value as property 但不是这样的: var obj = { obj.foo: ...
  • 您正在从名为patients的表中进行选择,因此在patient.patientid对patient的引用无效,对于patient.name (虽然我不知道为什么错误引用了as ,但它应该是“ 缺少FROM子句条目”表“病人” “) 另外:字符串常量需要放在单引号中,而不是双引号。 选择周围的括号是无用的。 以下应该有效: CREATE TEMPORARY TABLE IF NOT EXISTS temp_users AS SELECT p.patientid as patient FROM pati ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。