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

Wrong node coloring. #163

Closed
ps-pat opened this issue Aug 3, 2021 · 2 comments
Closed

Wrong node coloring. #163

ps-pat opened this issue Aug 3, 2021 · 2 comments

Comments

@ps-pat
Copy link

ps-pat commented Aug 3, 2021

The nodes coloring is wrong for some graphs. For instance,

using GraphRecipes
using Plots

g = [0 0 0 0 0 0 0 0 0;
     0 0 0 0 0 0 0 0 0;
     0 0 0 0 0 0 0 0 0;
     0 0 0 0 0 0 0 0 0;
     0 0 0 0 0 0 0 0 0;
     0 0 1 0 1 0 0 0 0;
     1 1 0 0 0 0 0 0 0;
     0 0 0 1 0 1 0 0 0;
     0 0 0 0 0 0 1 1 0]

colors = [:blue,
          :red,
          :blue,
          :red,
          :red,
          :blue,
          :blue,
          :blue,
          :blue]

graphplot(g, names = 1:9, nodecolor = colors)

produces the following plot:
gr

However, from my understanding, only nodes 2, 4 and 5 should be colored red.

@mroavi
Copy link

mroavi commented Aug 5, 2021

Duplicate of #153. Would be nice to know from the repo maintainers if there is any plan to work on this, or if, on the other hand, would be better to move to another solution like GraphMakie.

@BeastyBlacksmith
Copy link
Member

BeastyBlacksmith commented Jan 20, 2022

My understanding of this issue is the following: nodecolor is a 9-element vector, graphplot creates 18 series: 8 edges, 9 nodes, and one for the labels ( in that order ).
fillcolor will get cycled to match 18 series and since the nodes start 1 off, since its 8 edges before, you get the shift of colors and indeed if I hard code

    nodecolor isa Array && (nodecolor = permutedims(vcat(fill(nothing, 8), vec(nodecolor), nothing)))

I get the correct coloring for this example.

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