嘿,
今天我’d like to introduce you to a great R package that focuses on interactive time 系列 visualisation. The dygraphs
package is an R interface to the 音标交互式时间序列图库 which is implemented in JavaScript. dygraphs
provides really nice methods for plotting 时间序列 数据 interactively in R. These methods include (credits to the RStudio博客):
- 自动绘制xts时间序列对象(或其他可转换为xts的时间序列对象),
- 范围选择器界面,用于交互 交互式平移和缩放,
- 互动 系列/点高亮 具有不同的视觉选择
- 高度可配置 轴 和 系列 显示(包括可选 第二个Y轴),
- 显示 上/下杠 (例如误差线,预测区间),
- 各种图形叠加层,包括 阴影区域, 事件线和 注解,
- 与常规R图一样(通过RStudio Viewer)在R控制台上使用,
- 可嵌入 R Markdown 文件和 闪亮的 网络应用程序。
I have prepared a short application example using dygraphs to chart discharge 数据 from the river Danube in Austria below. Please note that function read_ehyd()
for importing the 数据 set can be found at 使用R从eHYD读取数据.
library(dygraphs) library(xts) # fetch 数据 for three Austrian gauges: Wildungsmauer, Melk 和 Aschach url <- c(wm = "http://ehyd.gv.at/eHYD/MessstellenExtraData/owf?id=207373&file=4", me = "http://ehyd.gv.at/eHYD/MessstellenExtraData/owf?id=207134&file=4", ah = "http://ehyd.gv.at/eHYD/MessstellenExtraData/owf?id=207035&file=4") discharge <- do.call(cbind, lapply(url, read.ehyd)) # plot w/ dygraph dygraph(discharge, main = "Discharge of River Danube") %>% dyRangeSelector() %>% dySeries("wm", label = "Wildungsmauer") %>% dySeries("me", label = "Melk") %>% dySeries("ah", label = "Aschach") %>% dyHighlight(highlightCircleSize = 5, highlightSeriesOpts = list(strokeWidth = 3), highlightSeriesBackgroundAlpha = 0.2, hideOnMouseOut = FALSE) # time 系列 with 数据 coverage for all gauges common.start <- index(head(na.omit(discharge), 1)) dygraph(discharge[index(discharge) >= common.start, ], main = "Discharge of River Danube") %>% dyRangeSelector() %>% dySeries("wm", label = "Wildungsmauer") %>% dySeries("me", label = "Melk") %>% dySeries("ah", label = "Aschach") %>% dyHighlight(highlightCircleSize = 5, highlightSeriesOpts = list(strokeWidth = 3), highlightSeriesBackgroundAlpha = 0.2, hideOnMouseOut = FALSE)
这就是结果图的样子:
7条留言
您可以在这篇文章中发表评论。
亲爱的马蒂亚斯,
非常感谢您的精彩帖子。有没有一种方法可以将图形嵌入到Keynote,Power Point或Prezi中?再次感谢您的工作!
我最好的,
亚历西奥
阿莱西奥·博科(Alessio Bocco) 3年前
亲爱的阿莱西奥,
由于我几乎不在演示文稿中使用交互式绘图,因此我从未考虑过这个问题。
我不知道将笔画图包含到任何上述演示软件中的简单方法。
但是,您可以在R Studio中将字形图保存为独立的HTML文档。
可能最简单的方法是直接使用RStudio,编织文档或导出HTML文件并使用浏览器显示它。
问候,
马蒂亚斯
马蒂亚斯 3年前
正如Matthias指出的那样,您应该了解Rmarkdown,尤其是ioslides。以下是一些链接:
http://data-analytics.net/cep/Schedule_files/presentations_demo.html
http://rmarkdown.rstudio.com/ioslides_presentation_format.html http://rmarkdown.rstudio.com/gallery.html
或闪亮的R:
//shiny.rstudio.com/
干杯
马丁
马丁 3年前
您好Alessio,
我也在寻找一种将笔画嵌入到Powerpoint演示文稿中的方法。您找到解决方案了吗?
谢谢!
还要感谢Matthias的出色帖子!
丽娜 3年前
您好Matthias,
感谢您提供的信息页面。
关于突出显示我有一个问题。我想将更多信息(不仅是突出显示的数据点的时间和y值)传递到工具提示(或本例中的图例)。
你有什么建议?
我认为我可以使用dygraph包中的dyCallBack函数来获取额外的信息,但不确定是否应该将其传递到图例区域。如果您可以通过一个简单的示例向我展示,将不胜感激。谢谢。
埃森 3年前
你好
I’m not 100% sure if I get what you intend to do. Are you looking for something in the lines of
dyAnnotation
?一个最小的示例(从其帮助页面复制)是:
最好的祝福,
马蒂亚斯
马蒂亚斯 3年前
嗨,我知道已经很久了,但是您还记得您是如何偶然解决问题的吗?
格罗斯 1年前
发表回复