-
Notifications
You must be signed in to change notification settings - Fork 40
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
Different labels for bidirectional arrows #92
Comments
The text object for label
from netgraph import Graph
import matplotlib.pyplot as plt
edges = [("in", "out"), ("out", "in")]
edge_labels = {
("in", "out"): 3,
("out", "in"): 5,
}
graph = Graph(edges, node_labels=True, node_label_offset=(1e-4, 0),
edge_labels=edge_labels, edge_label_position=0.33, arrows=True)
plt.show()
from netgraph import Graph
import matplotlib.pyplot as plt
edges = [("in", "out"), ("out", "in")]
edge_labels = {
("in", "out"): 3,
("out", "in"): 5,
}
graph = Graph(edges, node_labels=True, node_label_offset=(1e-4, 0), edge_labels=edge_labels,
edge_layout="curved", edge_layout_kwargs=dict(bundle_parallel_edges=False),
arrows=True)
plt.show()
from netgraph import MultiGraph
import matplotlib.pyplot as plt
# MultiGraph edges require an additional `key`, to distinguish edges connecting the same nodes in the same direction
edges = [("in", "out", 0), ("out", "in", 0)]
edge_labels = {
("in", "out", 0): 3,
("out", "in", 0): 5,
}
graph = MultiGraph(edges, node_labels=True, node_label_offset=(1e-4, 0), edge_labels=edge_labels, arrows=True)
plt.show() |
Oh wow, thank you so much for the excellent answer! That totally clears me up on how to proceed. I still think it's unideal that the default Maybe it's also worth mentioning |
Agreed. However, I am trying pretty hard to keep things stable, and am hence reluctant to change behaviours that have been the default since version 0.0.0.
I will add a section to the tutorial along the lines of my pointers above, and issue a warning pointing to said tutorial, when a user
So far, only the dev branch implements |
Sounds good, like your proposal! Thanks 👍 When updating the docs, my request is to include renderings of graphs involving bidirectional arrows. When I was reading the docs, I was visually skimming for examples of bidirectional arrows |
What is missing in basic example #2: directed graphs then? |
The renderings are great, I really like example 2. If you want to robust-ify it, then maybe add a second visualization showing separate labels on the bidirectional arrows |
This code, with
netgraph==4.13.2
andmatplotlib==3.9.0
:Renders like so:
We can see it clobbered the
3
label. Any chance we can support bidirectional arrows, that have a different label per direction?The text was updated successfully, but these errors were encountered: