Feature Request: Edge Style (Solid and Dashed Lines) in python-igraph
Please elaborate? I believe this is already working
Thank you for your reply. I have checked all the available parameters for edges, but I didn't find any parameter similar to edge.lty in R to control the drawing of solid and dashed lines. Is there any parameter that can achieve this? I am using the Matplotlib backend.
Try edge_linestyle
Thank you for your reply. I tested the edge linestyle parameter but it doesn't seem to work as expected. It only draws solid lines. Is there something wrong with my code or is this a known issue?
Here is my code:
import igraph as ig
import matplotlib.pyplot as plt
g = ig.Graph(edges=[[0, 1], [1, 2], [2, 3], [3, 0]])
edge_linestyles = ['-', '--', ':', '-.']
g.es['linestyle'] = edge_linestyles
fig, ax = plt.subplots()
ig.plot(g, target=ax, edge_linestyle=g.es['linestyle'])
plt.savefig("graph_with_different_linestyles.png", dpi=300)
Not sure ATM, I'm traveling with the kids so it might take a day or two before I can try this out.
Let's see if anyone else happens to know, otherwise I'll get back to you
I am developing a new package to improve plotting of graphs/networks in Python using igraph or networkx, it's called iplotx. It's designed to make all these things easy. In your case:
import igraph as ig
import matplotlib.pyplot as plt
import iplotx as ipx
g = ig.Graph(edges=[[0, 1], [1, 2], [2, 3], [3, 0]])
layout = [[0, -1], [1, 0], [0, 1], [-1, 0]]
style = {
'vertex': {
'facecolor': 'red',
'edgecolor': 'black',
'linewidth': 2,
},
'edge': {
'linestyle': ['-', '--', ':', '-.'],
}
}
fig, ax = plt.subplots()
ipx.plot(
network=g,
layout=layout,
style=style,
ax=ax,
)
plt.ion()
plt.show()
and you'll end up with what you want:
NOTE: iplotx does NOT compute layouts (for now), so you can use igraph for that.
Link to the package: https://github.com/fabilab/iplotx You can install it from pip
Link to the package: https://github.com/fabilab/iplotx You can install it from pip
Thank you for your reply