我正在尝试在ggraph网络中使用图像(例如,国家旗帜)。我希望使用ggimage的geom_image,但是我认为该函数需要调整以适用于不指定x和y坐标的ggraph。
library(tidygraph)
library(ggraph)
library(ggimage)
r <- create_notable('bull') %>%
mutate(class = sample(letters[1:3], n(), replace = TRUE),
image = "https://upload.wikimedia.org/wikipedia/en/7/7d/Lenna_%28test_image%29.png")
ggraph(r, 'stress') +
geom_node_point() +
geom_edge_link()
r %>%
as_tibble() %>%
ggplot(aes(x = runif(nrow(.)), y = runif(nrow(.)))) +
geom_image(aes(image = image))
# I would like this to work:
ggraph(r, 'stress') +
geom_node_image(aes(image = image)) +
geom_edge_link()发布于 2020-12-28 00:34:28
ggraph确实不要求您指定X和Y坐标,但这是一种便利。变量名为x和y。你可以明确地说:
ggraph(r, 'stress') +
geom_node_point(aes(x = x, y = y))这些变量可用于所有其他ggplot-related函数,包括ggimage::geom_image()。
ggraph(r, 'stress') +
geom_edge_link() +
geom_image(aes(x = x, y = y, image = image))

https://stackoverflow.com/questions/65467871
复制相似问题