Reputation: 35
I plan to use EditableGraph
of Netgraph
as the foundation of my application. However, I have encountered the following issue. Let us consider the following program that draws a small graph.
import matplotlib.pyplot as plt
from netgraph import EditableGraph
from numpy import array
fig,ax = plt.subplots()
editgraph = EditableGraph([(0,1),(0,2),(2,2)],
node_label_fontdict=dict(size=9),
node_labels=True,
edge_width=2,
node_layout= {0: array([0.5, 0.5]), 1: array([0.25, 0.5]), 2: array([0.75, 0.5])},
ax=ax)
plt.show()
If:
Initiated writing label(s).
C:\Users\...\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\netgraph\_main.py:1082: UserWarning: Plotting of edge labels for self-loops not supported for straight edges.
Ignoring edge with label:
warnings.warn(msg)
Traceback (most recent call last):
File "C:\Users\...\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\matplotlib\cbook.py", line 298, in process
func(*args, **kwargs)
File "C:\Users\...\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\netgraph\_interactive_variants.py", line 518, in _on_key_press
self._edit_labels(event.key)
File "C:\Users\...\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\netgraph\_interactive_variants.py", line 550, in _edit_labels
self._edit_edge_label(artist, key)
File "C:\Users\...\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\netgraph\_interactive_variants.py", line 571, in _edit_edge_label
self._edit_text_object(self.edge_label_artists[edge], key)
~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
KeyError: (1, 1)
The resulting graph is as follows:
Moreover, I have not encountered any problems with edges that are not self-loops.
What is the problem with this example that prevents adding a label to a new self-loop? Why does labeling the existing self-loop enable the possibility to label the created self-loop?
How can this issue be fixed? It would be helpful to be able to label the self-loop using EditableGraph
regardless of the protocol used.
Upvotes: 0
Views: 102