在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 baseplot
. 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 withggplot2
?Ideally, I want to be able to display multiple
geom_line
s. 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
最满意答案
对象属性是这样设置的:
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.)
-
语法错误(error in syntax)[2022-02-25]
这将有效: $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 ...
-
语法错误(Syntax Error)[2022-06-08]
但是,现在编写语句的方式将起作用(一旦将列引用添加到case语句,正如其他文章所述),但是,让其余语法不加注释将会对其他人的情况造成损害。 虽然你可能只需要运行这个查询一次,但我和其他人遇到类似的情况,即多行Update也依赖于离我们源数据3或4个表的数据,并且必须多次运行(比如在报告中) 。 通过将你的子选择合并成单个select语句并将结果保存到#Temp表或一个@Table变量中,你只需要执行一次查找,然后从结果集中选择更新。 以下是使用@table变量的示例: declare @OilStatus ... -
IF语法错误(IF syntax error)[2022-02-03]
您的查询仅在存储过程/函数上下文中有效。 在那里参考。 Your query is only valid in a stored procedure/function context. See there for reference. -
Haskell语法错误在哪里(Haskell syntax error in where)[2022-02-15]
其他人已经指出错误是由对齐错误引起的,您可以通过将first , second , third和fourth与words对齐来修复 - 即将它们向右移动两列。 除此之外,我想指出两件事: words不是一个非常幸运的名字,因为它是Prelude中标准库函数的名称。 通过注意你的代码 - 对于长度为4的字节toIntegral - 解包字节toIntegral ,然后在每个元素上调用toIntegral然后使用(.|.)折叠列表,你可以完全离开。 即我认为你也可以做类似的事情 bs2int' :: B.Byt ... -
语法错误在哪里(Where is the syntax error)[2022-06-19]
对象属性是这样设置的: 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: ... -
“AS”附近的语法错误(Syntax error near “AS”)[2022-08-04]
您正在从名为patients的表中进行选择,因此在patient.patientid对patient的引用无效,对于patient.name (虽然我不知道为什么错误引用了as ,但它应该是“ 缺少FROM子句条目”表“病人” “) 另外:字符串常量需要放在单引号中,而不是双引号。 选择周围的括号是无用的。 以下应该有效: CREATE TEMPORARY TABLE IF NOT EXISTS temp_users AS SELECT p.patientid as patient FROM pati ...