briatte / ggnetwork

Geoms to plot networks with ggplot2
https://briatte.github.io/ggnetwork/
146 stars 28 forks source link

plotly support ? #77

Closed BioLaoXu closed 2 months ago

BioLaoXu commented 2 months ago

ggnetwork is a very good project, but I tested the conversion that doesn't seem to support plotly, I don't know what caused it, and I'm looking forward to your reply。

library(ggnetwork)

a=rgraph(10, tprob = 0.2)
# colnames(a)=LETTERS[1:ncol(a)]
# rownames(a)=letters[1:nrow(a)]
n <- network(a, directed = FALSE)
n %v% "family" <- sample(letters[1:3], 10, replace = TRUE)
n %v% "importance" <- sample(1:3, 10, replace = TRUE)
e <- network.edgecount(n)
set.edge.attribute(n, "type", sample(letters[24:26], e, replace = TRUE))
set.edge.attribute(n, "day", sample(1:3, e, replace = TRUE))
n=ggnetwork(n, layout = "fruchtermanreingold", cell.jitter = 0.75)
# n=ggnetwork(n, layout = "target", niter = 100)

ggplot(n, aes(x = x, y = y, xend = xend, yend = yend)) +
  geom_edges(aes(linetype = type), color = "grey50") +
  theme_blank()

gg=ggplot(n, aes(x = x, y = y, xend = xend, yend = yend)) +
  geom_edges(color = "black") +
  geom_nodes(color = "black", size = 8) +
  geom_nodetext(aes(color = family, label = LETTERS[ vertex.names ]),
                fontface = "bold") +
  theme_blank();gg

ggplotly(gg)

###################################################################
Error in match.fun(FUN) : 
  'ggfun("scales_transform_df")' is not a function, character or symbol

Here's my operating environment

> sessionInfo()
R version 4.2.1 (2022-06-23)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 20.04.4 LTS

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3
LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/liblapack.so.3

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C               LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8     LC_MONETARY=en_US.UTF-8   
 [6] LC_MESSAGES=en_US.UTF-8    LC_PAPER=en_US.UTF-8       LC_NAME=C                  LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] parallel  grid      stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] plotly_4.10.1         geomnet_0.3.1         sna_2.7               statnet.common_4.7.0  network_1.18.0        ggnetwork_0.5.13      visNetwork_2.1.2     
 [8] ggfittext_0.10.0.9000 forcats_0.5.2         tidyHeatmap_1.10.1    rlang_1.1.1           GGally_2.1.2          paletteer_1.5.0       graphlayouts_0.8.3   
[15] circlize_0.4.15       ggcorrplot_0.1.4      ggfortify_0.4.15      ComplexHeatmap_2.12.1 psych_2.2.9           ggnewscale_0.4.7      openxlsx_4.2.5       
[22] processx_3.8.2.9000   this.path_2.2.0       cowplot_1.1.1         ggpubr_0.6.0          sf_1.0-9              ggVennDiagram_1.5.2   VennDetail_1.12.0    
[29] ggplotify_0.1.0       png_0.1-8             pathview_1.36.1       stringr_1.5.0         tidytext_0.3.4.9000   RColorBrewer_1.1-3    tibble_3.2.1         
[36] ggpmisc_0.5.1         ggpp_0.4.5            patchwork_1.1.2       data.table_1.14.8     ggrepel_0.9.3         BiocFileCache_2.4.0   dbplyr_2.2.1         
[43] tidyr_1.3.0           ggkegg_1.3.1          XML_3.99-0.14         ggraph_2.1.0          ggplot2_3.5.1         igraph_2.0.3          dplyr_1.1.2          
[50] tidygraph_1.2.2      
BioLaoXu commented 2 months ago

I updated plotly with no errors, and I'm going to close this issue