I have generated a very simple network plot with a circular layout using ggraph. The angle of node labels changes along the edge of the circle to make it easier to read these. However, the labels are truncated and adjusting margins seems to make no difference. I played around with ggsave, egg and have not had much joy.
Here is my reproducible code. Maybe somebody can help me. Thanks in advance:
# load network packages
require(tidygraph)
require(igraph)
# fetch data from github
githubURL <- "https://github.com/aterhorst/data/raw/master/network.RDS"
network <- readRDS(url(githubURL))
# compute label angles
require(pracma)
lo <- layout.circle(network)
angle <- as_tibble(cart2pol(lo)) %>% mutate(degree = phi * 180/pi)
# generate plot
require(ggraph)
ggraph(network, layout = "circle") +
geom_edge_link() +
geom_node_point() +
geom_node_text(aes(label = name),
size = 2,
hjust = ifelse(lo[,1] > 0, -0.2, 1.2),
angle = case_when(lo[,2] > 0 & lo[,1] > 0 ~ angle$degree,
lo[,2] < 0 & lo[,1] > 0 ~ angle$degree,
lo[,1] == 1 ~angle$degree,
TRUE ~ angle$degree - 180)) +
theme_graph()
dropping theme_graph(), i found that the axis is -1 to 1 for both x and y, and it doesnt seem to fit the labels. So I added coord_cartesian() to expand the limit of the plot. Have below added to ggraph()
+ coord_cartesian(xlim=c(-1.2,1.2), ylim=c(-1.2,1.2))