Hi
I was trying to use the “vertex_label_dist” and “vertex_label_angle” to adjust the position of vertex labels, but it seems they are not working with matplotlib backend. I also tried to use cairo backend and they work fine in cairo backend. I attached the plots and my code here. I wonder whether there is problem in my code or the two settings are not available for matplotlib backend.
Plot of cairo:
Plot of matplotlib:
Code:
# Construct a graph with 3 vertices
n_vertices = 5
edges = [(0, 1), (0, 2), (0, 3), (0, 4), (1, 2), (1, 3), (1, 4), (3, 4)]
g = ig.Graph(n_vertices, edges)
# Set attributes for the graph, nodes, and edges
g["title"] = "Small Social Network"
g.vs["name"] = ["Daniel Morillas", "Kathy Archer", "Kyle Ding", "Joshua Walton", "Jana Hoyer"]
g.vs["gender"] = ["M", "F", "F", "M", "F"]
g.es["married"] = [False, False, False, False, False, False, False, True]
# Set individual attributes
g.vs[1]["name"] = "Kathy Morillas"
g.es[0]["married"] = True
fig, ax = plt.subplots(figsize=(5, 5))
visual_style = {"vertex_size": 15,
"vertex_color": "lightblue",
"vertex_label": g.vs["name"],
"vertex_label_angle": 3,
"vertex_label_dist": 20,
"edge_width": 2,
"vertex_frame_color": "black",
"layout": "circle",
"margin": 0.8}
ig.plot(
g,
# target=ax,
**visual_style
)
plt.show()
# Export and import a graph as a GML file.
g.save("social_network.gml")
g = ig.load("social_network.gml")