Comments (4)
Hi,
I think I know what's the problem, I believe that it might be related to the offset used when drawing edges. In the current implementation, the offset is set as the size of the node, which works well when using circular shapes because the distance from the edge of the circle to the center of the shape is the same, regardless of the angle.
However, when using "non-uniform" shapes like triangles, the offset should depend on the angle. For non-directed graphs, a quick workaround is to reduce the offset, for example, with node_size[target] * 0.5. However, this solution might not work with directed graphs as the arrow may get hidden by the node. Additionally, it may cause strange artifacts when using small nodes and thick edges.
from netgraph.
Hi Hicham,
Yeah, this is a known issue. The problem is very similar to issue #37, which is about providing support for arbitrary node shapes derived from text boxes, which runs into the same sort of problems. You are also absolutely right with your diagnosis, as well as the assessment that there isn't an easy fix that doesn't cause problems in other places. In issue #37, I outlined some of the things that I believe would need to be done to properly address this problem, and I have even started to work on it on a (local) branch.
In theory, the solution is quite straightforward: simply compute the intersection between the matplotlib Path
that defines the node artist and then shorten the edge accordingly. This approach works well for paths forming convex polygons. The problem that I got stuck on was how to handle paths that are Bezier curves (i.e. circles and rectangles with rounded corners, for example). Here, the path does not correspond to the outline of the patch but only defines it implicitly.
Properly supporting arbitrary node shapes also raises issues in other places, e.g. with the automatic scaling of node label fontsizes.
All of this a long-winded way of saying that I am interested in properly handling arbitrary node shapes and actively working on it but the problem is complex. Since I am short on time at the moment (work is busy and I have a 9 month old baby at home), it will take me a good while (months not days) until the issue will be resolved. If you are interested in working on this in the meantime, I am happy to draw up a proper roadmap.
Thanks for chiming in on the other issue,
Paul
from netgraph.
Some progress:
from netgraph.
On the dev
branch, edges now connect precisely to their targets for arbitrary node shapes.
I am in the process of preparing a new major release, and it hence will be some time until dev
will get merged into the master
branch. To install the dev
branch, use:
pip install https://github.com/paulbrodersen/netgraph/archive/dev.zip
from netgraph.
Related Issues (20)
- Problems with very large graphs HOT 12
- Installation not working with python 3.11 HOT 5
- Minor documentation issues HOT 3
- ArcDiagram throws warning, does not label nodes, does not preserve node order. HOT 2
- Way to specify linestyle for edges? HOT 2
- Unable to use Community layout for Multi-Component graph? HOT 4
- Issues with MultiGraph HOT 14
- Not specifying node_edge_width when node_size is small causes node colours to not show up HOT 2
- How can I change the direction of a dot graph? HOT 1
- Strange Axis BoundingBox "diamond" HOT 3
- Combining interactive graphs with networkx subgraph functions? HOT 6
- (Suggestion) Handling div-by-zero HOT 1
- (Un)directed mixed graph HOT 5
- Changing arrow size while keeping edge width intact HOT 3
- self-loop labeling problem using EditableGraph HOT 2
- Embedding NetGraph EditableGraph in PyQt5 HOT 3
- Bundle_parallel_edges problem HOT 4
- Fixed node size in Netgraph ? HOT 18
- Add multiple edges simultaneously HOT 12
- Overlapping nodes Fix HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from netgraph.