试图为ggrepel(geom_text_repel)构建一个情节钩子

Ted*_*sby 5 r ggplot2 shiny plotly ggrepel

下面的链接讨论了如何使用gets3methods调用来构建一个钩子to.basic.然而,这仅适用于可以分解为更简单的geoms(geom_lineto geom_path)的geoms .因为geom_text_repel我不确定是否可能.

它继续提到你必须为它创建一个自定义方法geom2trace.怎么会这样做呢?我是S3数据指南的新手并做了类似的事情,所以我不确定从哪里开始.

如果我跑了methods(geom2trace)我得到:

> methods(geom2trace)
 [1] geom2trace.default*       geom2trace.GeomBar*       geom2trace.GeomBlank*     geom2trace.GeomBoxplot*   geom2trace.GeomErrorbar* 
 [6] geom2trace.GeomErrorbarh* geom2trace.GeomPath*      geom2trace.GeomPoint*     geom2trace.GeomPolygon*   geom2trace.GeomText*     
[11] geom2trace.GeomTile*     
see '?methods' for accessing help and source code
Run Code Online (Sandbox Code Playgroud)

我看到geom2trace.GeomText这里似乎需要的东西.

在我尝试创建交互式wordcloud时,这里的任何指导都将是一个巨大的帮助!很高兴分享这个项目的成果.

在更复杂的情况下,您的自定义geom无法转换为较低级别的geom,需要geom2trace()泛型的自定义方法(方法(geom2trace)列出我们原生支持的所有基本geom).此方法应涉及从数据框到符合plotly.js图引用的类似列表的对象的转换.

https://plotly-book.cpsievert.me/translating-custom-ggplot2-geoms.html