Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/spring-mvc/2.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 难以理解自定义几何图形的ggplotly接口_R_Ggplot2_Ggplotly - Fatal编程技术网

R 难以理解自定义几何图形的ggplotly接口

R 难以理解自定义几何图形的ggplotly接口,r,ggplot2,ggplotly,R,Ggplot2,Ggplotly,我已经取得了一些成功,现在我正努力使这个扩展与ggplotly()配合使用。详细的文档,基本上可以归结为为为geom提供to_basic方法或geom2trace方法 老实说,我已经深不可测了,我正试图根据两个命名的例子来拼凑一些东西:和。但是一些简单的事情,比如: #' @name plotly_helpers #' @title Plotly helpers #' @description Helper functions to make it easier to automatically

我已经取得了一些成功,现在我正努力使这个扩展与
ggplotly()
配合使用。详细的文档,基本上可以归结为为为geom提供
to_basic
方法或
geom2trace
方法

老实说,我已经深不可测了,我正试图根据两个命名的例子来拼凑一些东西:和。但是一些简单的事情,比如:

#' @name plotly_helpers
#' @title Plotly helpers
#' @description Helper functions to make it easier to automatically create plotly charts
#' @importFrom plotly to_basic
#' @export
to_basic.GeomFlag <- getFromNamespace("to_basic.GeomPoint", asNamespace("plotly"))
如果我将其更改为GeomLine,则程序包将记录并安装,但一个简单的绘图显示如下所示:

df = data_frame(
    f = rep(1:5, each = 4),
    x = rep(1:4, times = 5),
    y = c(1:2, 2:1, 2:1, 1:2, 1:2, 2:1, 2:1, 1:2, 2:1, 1:2),
    s = c(1:4, 4:1, 1:4, 4:1, 1:4),
    c = rep(c('au', 'us', 'gb', 'de'), 5))

p1 = ggplot(df) + geom_flag(aes(x = x, y = y, size = s, frame = f, country = c)) + scale_country()
ggplotly(p1)

显然GeomLine不正确GeomPoint似乎是这个扩展的一个更自然的点,但它可能只是因为我不能减少它,我需要实现
geom2trace
。但我并不十分清楚这两种方法都需要做些什么。有人能帮忙吗?是否有其他实现Plotly接口的
ggplot2
扩展的示例


编辑:我已经看过了,但我不确定我能在这里走得更远。我有点希望我可以用自定义的GROB代替GeomPoint点,比如使用
网格
,但Plotly API似乎只需要基本的点属性。

Hi@rensa,你知道这一点吗?我正试图做本质上相同的事情。不幸的是没有,@bmac;我在plotly论坛上寻求了一些帮助,但看起来定制几何图形至少需要由plotly提供的轨迹组成。最后,我决定使用grid2SVG从ggplot2导出SVG,并使用jQuery(或d3,或其他任何工具)自己制作动画。我讨论了这项技术的一个例子,我正在研究其他一些例子,我很快就会写出来:)好的,谢谢你关注@rensa,我会查看这个链接!
df = data_frame(
    f = rep(1:5, each = 4),
    x = rep(1:4, times = 5),
    y = c(1:2, 2:1, 2:1, 1:2, 1:2, 2:1, 2:1, 1:2, 2:1, 1:2),
    s = c(1:4, 4:1, 1:4, 4:1, 1:4),
    c = rep(c('au', 'us', 'gb', 'de'), 5))

p1 = ggplot(df) + geom_flag(aes(x = x, y = y, size = s, frame = f, country = c)) + scale_country()
ggplotly(p1)