Comments (4)
Hi, thanks for raising the issue and explaining in detail what you mean. I get it now. ;-)
to allow each node artist to have attributes responsible for different height and width
Strictly speaking, even that would not be enough, as node artists can be triangles, for example.
The more I think about it, the more it seems that we might want to emulate matplotlib's FancyArrowPatch
, which supports a patchA
and a patchB
parameter. These can be arbitrary patch objects, and matplotlib uses them to clip the path that then forms the midline of the arrow.
from netgraph.
I've spent more time studying source code of netgraph
this week. In conclusion, I've found that node and edge artist objects are inherited from matplotlib.patches.PathPatch
class. It doesn't look to have support for pointing edges to any kind of labels. matplotlib.patches.PathPatch
is also scalable unlike text of node labels. This might be another issue. So, indeed, the only remaining option is FancyArrowPatch like in my answer. I'm OK with rectangular shapes at the moment.
I guess this functionality requires a lot of changes of current version. Could we expect them in the future versions of netgraph
?
from netgraph.
It doesn't look to have support for pointing edges to any kind of labels.
That is correct. Edges point to nodes, not the node labels. Netgraph supports placing node labels with an offset, i.e. outside of the node artist (/PathPatch), so pointing edges at node labels would not make much sense in the context of the rest of the code base.
However, by default, iff the node labels are plotted centered on the node artists (i.e. without an offset), netgraph scales the font size of node labels such that all labels fit inside their node artists. Hence for me implementing this feature is equivalent to
- supporting arbitrary node shapes, while
- handling the node and edge artist overlaps more precisely.
I think you are imagining plotting the graph without any node artists and using the text bounding box as a node artist replacement. However, that would break pretty much everything else in the current code base (e.g. everything interactive), so any support for that will only ever be accidental.
I guess this functionality requires a lot of changes of current version.
If it is implemented the way that I am imagining it, I don't think it is too bad. I suspect almost all of the changes are isolated to _artists.py so the problem is quite self-contained.
NodeArtist
in _artists.py would need a redesign to support arbitrary node shapes.- The
offset
parameter inEdgeartist
would have to be replaced by references to the artists of the source and target nodes of that edge. Then the path of the node artists patches could be used to clip the midline path inEdgeArtist._update_path
. IIRC, matplotlibPatch
instances have aclip_path
method so that shouldn't be too hard.
Outside of _artists.py, I only expect minor changes in _main.py, specifically
BaseGraph._get_font_size
would need a different way to determine the font size of a node label such that it fits the node artistBaseGraph.draw_edges
would have to pass in the source and target node artists toEdgeArtist
, which would be trivial.
That should be it, mostly?
Could we expect them in the future versions of netgraph?
It's fairly high on my netgraph todo list but I have a lot of work on my plate (of the type that pays bills) and my firstborn is due in a month. So if it doesn't happen in the next couple of weeks, it might be quite some time until I have enough head space to continue development on netgraph.
from netgraph.
On the dev
branch,
- nodes can now have arbitrary shapes (specified by
matplotlib.path.Path
instances), and - edges connect precisely to their targets for arbitrary node shapes.
This should allow you to create rectangular nodes, that can then serve as text boxes.
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)
- Multipartite/Shell layouts not working if the number of nodes per layer/shell are not equal HOT 1
- Opacity behavior when removing vertex HOT 2
- 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
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.