5

下面的链接讨论了如何gets3methods使用to.basic. 但是,这仅适用于被分解为更简单的 geom ( geom_lineto geom_path) 的 geom。因为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

我看到一个geom2trace.GeomText似乎在这里需要的东西。

这里的任何指导都会对我尝试创建交互式 wordcloud 有很大帮助!也很高兴分享这个项目的成果。

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

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

4

0 回答 0