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

plot graph with dot #1

Closed
kexul opened this issue Apr 24, 2021 · 2 comments
Closed

plot graph with dot #1

kexul opened this issue Apr 24, 2021 · 2 comments

Comments

@kexul
Copy link

kexul commented Apr 24, 2021

Hi, I've seen your discussion here michellab/BioSimSpace#193 , @JenkeScheen said:

if you've done any work on LOMAP network generation to show within a notebook that would be very helpful! It's starting to look like the LOMAP build I currently have is unable to draw a decent-looking network to show in an ipynb.

The network drawn by pygraphviz has several drawbacks:
1. The edge would be covered by molecule image.
2. The molecule image would cover each other when there are many molecule pairs.
I would recommend use dot to generate network graph as LOMAP have done, which doesn't have the drawbacks listed above.
I've copied some code from my project and created a gist to show how to do that with several lines:
https://gist.github.com/kexul/044340c773822c7748c722b9e2e082e2

Core lines:

  1. Add image file and label, here labelloc='t' means label is at top of node.
G.add_node(name, image=fname, label = name, labelloc='t')
  1. Generate .dot file and convert it to .png.
nx.nx_agraph.write_dot(G, f'temp/{file_name}.dot')
os.system(f'dot -Tpng temp/{file_name}.dot -o temp/{file_name}.png')

image

@lohedges
Copy link
Member

Thanks, @kexul. This is very helpful. I agree that the network plot quickly becomes a mess as the number of ligand pairs grow. This seems like a great approach and will be easy to implement.

@JenkeScheen
Copy link
Collaborator

JenkeScheen commented Apr 24, 2021 via email

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