paulbrodersen / netgraph

Publication-quality network visualisations in python
GNU General Public License v3.0
660 stars 39 forks source link

Changing arrow size while keeping edge width intact #83

Open Jojo6297 opened 5 months ago

Jojo6297 commented 5 months ago

Dear authors,

Is there a way to change the arrow size of the directed edges, while keeping the edge width intact? I tried to add in edge_kwargs = dict(arrow_size = arrow_size), but it doesn't work.

Thanks!

paulbrodersen commented 5 months ago

It's not a feature that is properly supported but it can be done by instantiating the Graph object (or any of the derived classes), and then manipulating each edge artist individually.

Figure_1

import matplotlib.pyplot as plt

from netgraph import Graph

fig, ax = plt.subplots()
g = Graph([(0, 1), (1, 2), (2, 0)], arrows=True, node_labels=True, ax=ax)
edge_artist = g.edge_artists[(0, 1)]
edge_artist.head_width = 0.05
edge_artist.head_length = 0.1
edge_artist._update_path()
plt.show()

You are not the only that is wanting to get fancy with arrows (see issue #82), so I will try it to come up with proper way for the next release. However, as there is no "authors", just me, this will still be a while.

Jojo6297 commented 5 months ago

Thanks for the workaround, and a super cool network tool!

paulbrodersen commented 5 months ago

Thanks for the kind words!