-
Notifications
You must be signed in to change notification settings - Fork 0
/
scrPlot.R
33 lines (21 loc) · 1.25 KB
/
scrPlot.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
graph=jsonlite::fromJSON("graph.json")
class(graph$nodes)
library(ggplot2)
ggplot(graph$nodes)+geom_point(aes(x=attributes$x,y=attributes$y,size=attributes$`nansi-indegree`,color=factor(attributes$`nansi-louvain`)))+
scale_size_area("",guide="none",max_size = 3)+
scale_color_brewer(palette="Set3",guide="none")+
theme_void()
library(dplyr)
graph$nodes |> group_by(attributes$`nansi-louvain`) |> top_n(3,attributes$`nansi-indegree`) |>
transmute(indeg=attributes$`nansi-indegree`,com=attributes$`nansi-louvain`,lab= attributes$`label`) |> arrange(com) |> View()
mapstodon = graph$nodes |> filter(attributes$label=="mapstodon.space")
labels = graph$nodes |>
transmute(label=attributes$label,x=attributes$x,y=attributes$y,indeg=attributes$`nansi-indegree`) |>
arrange(desc(indeg)) |>
filter(indeg>=20,!is.na(label))
ggplot(graph$nodes)+geom_point(aes(x=attributes$x,y=attributes$y,size=attributes$`nansi-indegree`,color=factor(attributes$`nansi-louvain`)))+
geom_point(data=mapstodon,aes(x=attributes$x,y=attributes$y,size=5*attributes$`nansi-indegree`),shape=1,color="red")+
geom_text(data=labels,aes(x=x,y=y,label=label),size=1.5)+
scale_size_area("",guide="none",max_size = 3)+
scale_color_brewer(palette="Set3",guide="none")+
theme_void()