Preventing Overlap Of Edges And Nodes With NetwrokX/Matplotlib
Solution 1:
Picking up on the really helpful comment from DYZ about using graphviz_layout()
, I thought I'd share my experience here, in case anyone else is having a similar issue, because getting this set up wasn't totally straightforward (for me, at least, on Ubuntu 16.04):
I found sudo pip install pygraphviz
didn't work, because it couldn't find one of the files it needed. I then tried sudo apt-get install graphviz libgraphviz-dev pkg-config
followed by sudo pip install pygraphviz
(thanks to this suggestion), which looked like it worked (i.e. installation succeeded), but I still couldn't use graphviz_layout()
through NetworkX. So, I uninstalled pygraphviz
(sudo pip uninstall pygraphviz
) and installed it again as follows (thanks to a tip on this thread):
sudo pip install pygraphviz --install-option="--include-path=/usr/include/graphviz" --install-option="--library-path=/usr/lib/graphviz/"
This did work, and visualisations with graphviz_layout()
do seem to have less node overlap than using NetworkX's spring_layout()
, as well as a more æsthetically pleasing approach to edge length and cluster spacing.
Post a Comment for "Preventing Overlap Of Edges And Nodes With NetwrokX/Matplotlib"