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

Multiple Edge Colors #168

Open
jwassmer opened this issue Oct 12, 2021 · 5 comments
Open

Multiple Edge Colors #168

jwassmer opened this issue Oct 12, 2021 · 5 comments

Comments

@jwassmer
Copy link

An option to have multiple edge colors would be awesome. I would like to able to do something like this:

using Plots, GraphRecipes, Colors
g = [0 1 1;
     1 0 1;
     1 1 0]
graphplot(g,
          x=[0,-1/tan(π/3),1/tan(π/3)], y=[1,0,0],
          nodeshape=:circle, nodesize=1.1,
          axis_buffer=0.6,
          curves=false,
          edgecolor=[colorant"#389826",colorant"#CB3C33",colorant"#9558B2"],
          linewidth=10)

But at the moment you can only input single colors to edgecolor. Is there a workaround to do this?

@JasonPekos
Copy link

JasonPekos commented Jul 1, 2022

There's a pretty terrible hack, but if anyone is desperate:

  1. pick a method that's invariant to edge structure and non-random, e.g. :circular.
  2. plot your graph with the first colour you want for your edges.
  3. plot the subgraph of your original graph again with graphplot!() such that the only included edges are those that should be a different colour.

This should work. You can also show random walks over graphs using a DiGraph in your second plot call, e.g.

download-1

This is a little messy in places, but I think that could be cleaned up by setting curves to false or messing around with edge width.

@JasonPekos
Copy link

followup: if you want this specific feature, you might be better off using GraphMakie as of Jul 2022. It seems a little more feature complete here.

@gabrevaya
Copy link

gabrevaya commented Nov 8, 2022

Hi, I'm also interested in setting different colors to edges and to node borders. I found here that at some point it was possible to do it. Setting different edges colors still work with edge_z (eg, G is a SimpleWeightedDiGraph, you can set edge_z = (s,d,w) -> G.weights[d,s]). However, it's not possible to set different border colors for the nodes anymore. I'll open a new issue for this.

@bobaronoff
Copy link

I would also make use of this feature. Am using a simple DiGraph to display causal models. The desire is to color code paths as wether they represent a dependency and whether or not they are blocked. The logic is already coded but am stuck not being able to set the color of edges individually. edgecolor argument does not accept vector or dict.

@bobaronoff
Copy link

I may have posted too soon - my apologies. It is possible apply a multi-color scheme to edges. The solution seems to be to supply edgecolor with a dictionary and NOT a vector. The key of the dict is a tuple (s,d) that corresponds the edge designation. There needs to be a key for every edge. The value of the key is the color of that edge. I used Symbol values (i.e. :gray0, :red, :green, etc). This seems to be working. If this is correct, perhaps this info could be added to documentation.

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

4 participants