Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Edge-guide control #25

Closed
michaellevy opened this issue Dec 10, 2016 · 3 comments
Closed

Edge-guide control #25

michaellevy opened this issue Dec 10, 2016 · 3 comments

Comments

@michaellevy
Copy link

I am not able to control edge-color guides, whether legends or colorbars, and whether the color is set to an edge attribute or ..index.. A few examples:

library(ggraph)
library(igraph)
set.seed(82)
g = graph_from_edgelist(matrix(sample(letters, 100, TRUE), ncol = 2))
E(g)$type = rep(1:5, 10)

ggraph(g, lay = "igraph", alg = "kk") +
  geom_node_point() + 
  geom_edge_fan(aes(color = ..index..)) +
  scale_edge_color_gradient(breaks = c(.1, .9), labels = c("sender", "receiver")) + 
  guides(color = guide_colorbar(barwidth = 0.3))

# Throws an error:
# scale_edge_color_gradient(breaks = c(.1, .9), labels = c("sender", "receiver"),
#                           guide = guide_colorbar(barwidth = 0.3))

ggraph(g, lay = "igraph", alg = "kk") +
  geom_node_point() + 
  geom_edge_fan(aes(color = type)) +
  guides(color = guide_colorbar(barwidth = 0.3))

ggraph(g, lay = "igraph", alg = "kk") +
  geom_node_point() + 
  geom_edge_fan(aes(color = factor(type))) +
  guides(color = guide_legend("Title"))
@mdsumner
Copy link

"Me too". Was about to file this as well, here's my example in case it's helpful:

library(ggraph)
library(igraph)
hairball <- graph_from_data_frame(highschool)

E(hairball)$year <- as.character(E(hairball)$year)

## cannot turn of the colour guide
ggraph(hairball, layout = 'kk') + 
  geom_edge_link(aes(colour = year)) + guides(colour = FALSE)

I ran into this because I have a lot of edges I want to illustrate colours for, I will convert the values to a continuous scale for now.

Thanks!

@thomasp85
Copy link
Owner

The colour scale for edges is called edge_colour. Can I get you to test whether guides(edge_colour = FALSE) works

@mdsumner
Copy link

mdsumner commented Feb 17, 2017

Oops, it does work:

library(ggraph)
library(igraph)
hairball <- graph_from_data_frame(highschool)

E(hairball)$year <- as.character(E(hairball)$year)

## edge_colour guide
ggraph(hairball, layout = 'kk') + 
  geom_edge_link(aes(edge_colour = year)) + guides(edge_colour = FALSE)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants