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

Question regarding parameters when creating MatrixPlot or CircosPlot #675

Open
NiRuff opened this issue Nov 2, 2021 · 6 comments
Open
Labels

Comments

@NiRuff
Copy link

NiRuff commented Nov 2, 2021

When I am creating a MatrixPlot or CircosPlot like this everything works fine:

g = nv.arc(G, node_color_by="community", group_by="community")
annotate.arc_group(G, group_by="community")
g.get_figure().set_size_inches(10,10)

However, I wanted to adjust the edge width and set it by the weight in my weighted graph G.
I trid adding the parameter

edge_lw_by="weight"

But got the following error message:
data_linewidth() missing 1 required positional argument: 'ref_data'

Is this not implemented yet or am I doing something wrong here?

Also:
I would also like to adjust some options regarding opacity for the matrix plot - here I run into similar problems.

Thanks!!

P.S.:
From the code:

  • edge_lw_by: Edge metdata attribute key to set edge line width.
    • edge_alpha_by: Edge metdata attribute key to set edge transparency.
@AlirezaTheH
Copy link
Collaborator

Hi @NiRuff, thank you for letting us know. I think this is a small bug. We'll fix it soon.

@NiRuff
Copy link
Author

NiRuff commented Nov 3, 2021

Great, thanks a lot!

For all that are interested:
I uninstalled my current version of nxviz and then updated it using:

pip uninstall nxviz
pip install git+https://github.com/ericmjl/nxviz.git

When I ran the code like this it worked with drawing the edges with linewidth according to the Graph weights:

g = nv.arc(G, node_color_by="community", group_by="community", edge_lw_by="weight")

@AlirezaTheH: One more question: When having many groups with a lot of nodes the matrixPlot gets barely visible for me
Can I change the color scheme or make the black more prominent in the plot?
It looks like this e.g.:

grafik

@ericmjl
Copy link
Owner

ericmjl commented Nov 6, 2021

@NiRuff while it's technically possible to use edge_lw_by in a matrix plot, I might suggest doing edge_alpha_by instead. That might help a bit with the visualization, and it makes a bit more sense in this particular setting. The matrix plot is effectively a dot-matrix kind of plot; edge "width" would correspond to circle radius, but transparency is a better thing.

Perhaps something we should do here is to ensure that the dots actually have a border around them. What do you all think?

@NiRuff
Copy link
Author

NiRuff commented Nov 8, 2021

Thanks for the reply!

I used two versions ultimately: alpha and lw or just alpha. Unfortunately when having a lot of data the visibility is still poor.
Here the edge_alpha_by="weight" example:

grafik

Here having edge_alpha_by and edge_lw_by both set to "weight"
grafik

Unfortunately both are barely visible so I guess your suggestion might help here.

BTW: Thanks for reacting so fast all the time!

@ericmjl
Copy link
Owner

ericmjl commented Nov 8, 2021

I see what you mean, @NiRuff. Thanks for being patient here 😄.

The nature of large graphs means that the matrix would be difficult to visualize if you also wanted the transparency/lightness effect scaled by weight. I have a hunch you've hit the limits of what data visualization could do without considering the tradeoffs that need to happen.

The first I'd suggest is using panels of matrix plots rather than a single one. In this case, one plot to show clustering structure w/o showing weights, and another plot to show with weights. Put them side by side and you have a very effective data viz panel.

I believe there are two edge_kwargs that could help here, and you could use either one of them to start with. The first is the edge_alpha_scale kwarg, which lets you multiply the alpha (transparency) value by some scalar number across the board. The other is edge_alpha_bounds, which lets you set an upper-bound and lower-bound for transparency scaling. Those would result in visual inaccuracies but a more easily visualized single panel.

If I were in your shoes, though, I'd still use the first option. They make the data storytelling much easier.

@steepdescend
Copy link

Hi,

I was following along with Eric's scipy 2019 network analysis made simple tutorial and ran into this error message plotting the seventh grader network. Is this a related or new issue? (I saw what NiRuff said above and uninstall and reinstalled nxviz package but no change with the error.)

m = MatrixPlot(G)
m.draw()


TypeError Traceback (most recent call last)
~\AppData\Local\Temp/ipykernel_19744/2627178271.py in
1 m = MatrixPlot(G)
----> 2 m.draw()

TypeError: draw() takes 0 positional arguments but 1 was given

Any help is appreciated! thanks!

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

No branches or pull requests

4 participants