3

I'm trying to change the shape used in the legend from a square to circle with a fill aesthetic, but none of the override arguments seem to be working.

If:

library(ggraph)
library(igraph)

g <- graph_from_data_frame(highschool)

ggraph(g) + 
  geom_edge_link(aes(colour = factor(year))) +
  geom_node_point() +
  geom_edge_density(aes(fill = factor(year))) 

Adding:

guides(fill = guide_legend(override.aes = list(shape = c(21, 21)))) 

Produces this

[Produces this[1]

I'm not sure if it's possible to add an extra layer to the ggraph?

tjebo
  • 21,977
  • 7
  • 58
  • 94
T.P.
  • 87
  • 1
  • 6
  • 1
    usually, you would specify `fill = c(NA,NA)`, but this doesn't work here. In fact, the legend keys do not "react" to the usually modifications. I have the feeling that `ggraph` might not inherit `override.aes` arguments at all. I'd suggest to either re-build the plot with conventional `ggplot` methods (using `geom_line`, `geom_point` and `geom_density2d`) or making a fake legend with an extra plot and plot this next to your first plot – tjebo Feb 06 '20 at 15:16

0 Answers0