将多个chorddiag/htmlwidget图合并为R中的单个图
我正在 R 中生成几个 chorddiag
图,并希望将它们组合在一起形成一个图。下面是 3 个 chorddiag 图的示例列表:
library(chorddiag)
m <- matrix(c(11975, 5871, 8916, 2868,
1951, 10048, 2060, 6171,
8010, 16145, 8090, 8045,
1013, 990, 940, 6907),
byrow = TRUE,
nrow = 4, ncol = 4)
haircolors <- c("black", "blonde", "brown", "red")
dimnames(m) <- list(haircolors,haircolors)
groupColors <- c("#000000", "#FFDD89", "#957244", "#F26223")
ll <- lapply(1:3,function(i) chorddiag(m, groupColors = groupColors, groupnamePadding = 20))
如果这些是plotly 对象,我会使用plotly 的subplot 函数。对于以下情况是否有等效的内容:
> class(ll[[1]])
[1] "chorddiag" "htmlwidget"
I'm generating several chorddiag
plots in R and would like to combine them together to a single plot. Here's an example list of 3 chorddiag
plots:
library(chorddiag)
m <- matrix(c(11975, 5871, 8916, 2868,
1951, 10048, 2060, 6171,
8010, 16145, 8090, 8045,
1013, 990, 940, 6907),
byrow = TRUE,
nrow = 4, ncol = 4)
haircolors <- c("black", "blonde", "brown", "red")
dimnames(m) <- list(haircolors,haircolors)
groupColors <- c("#000000", "#FFDD89", "#957244", "#F26223")
ll <- lapply(1:3,function(i) chorddiag(m, groupColors = groupColors, groupnamePadding = 20))
If these were plotly object I'd use plotly's subplot function. Is there anything equivalent for case of:
> class(ll[[1]])
[1] "chorddiag" "htmlwidget"
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我还没有尝试过chorddiag包(我不认为它在CRAN上,也许是其他一些存储库?),但是manipulateWidget包可能就是你想要的。
example(combineWidgets)
具有以下代码:创建于 2022-03-24 reprex 包 (v2.0.1)
编辑为添加:
好的,我在 Github 上找到了
chorddiag
: https://github.com/马特弗洛/chorddiag/ 。运行代码后,这三个图表结合在一起:它们不能很好地调整大小;我怀疑这是因为
chorddiag
想要全屏显示,但也许这是manipulateWidgets
中的问题。您可能需要修补其中之一。I haven't tried the
chorddiag
package (I don't think it's on CRAN, maybe some other repos?), but themanipulateWidget
package may be what you want.example(combineWidgets)
has this code:Created on 2022-03-24 by the reprex package (v2.0.1)
EDITED to add:
Okay, I found
chorddiag
on Github: https://github.com/mattflor/chorddiag/ . After running your code, this combines the three diagrams:They don't resize nicely; I suspect that's because
chorddiag
wants to be fullscreen, but maybe it's a problem inmanipulateWidgets
. You'll probably have to patch one or the other.