1

Question: how can I rotate text on an igraph plot in python

I'm just trying to rotate text on a simple graph 45 degrees however adjusting the vertex_label_angle as suggested here seems to have no affect.

Included is a simplified example showing how other vertex attributes (colour, size, ect.) can be modified but not label angle.

import igraph as ig
import numpy as np

#PLOT WITH ALL TREES ATTACHED TO "ROOT"
Graph = ig.Graph()
Graph.add_vertex("root")

Graph.add_vertex("node1")
Graph.add_vertex("node2")
Graph.add_vertex("node11")
Graph.add_vertex("node12")

Graph.add_edge("root", "node1")
Graph.add_edge("root", "node2")
Graph.add_edge("node1", "node11")
Graph.add_edge("node1", "node12")

visual_style = {}
visual_style["vertex_label"] = Graph.get_vertex_dataframe()["name"]
visual_style["vertex_label_size"] = 20
visual_style["vertex_size"] = 30
visual_style["vertex_color"] = "blue"

visual_style["vertex_label_angle"] = -45 * (np.pi / 180) #angle is in radians


ig.plot(Graph, **visual_style)

I'm using python 3.7.4 on ubuntu 18.04.5 with igraph version 0.9.1

TCulos
  • 183
  • 3
  • 13
  • `label_angle` does not rotate the text. Instead, it sets the direction in which to offset the label (`label_dist`) from the vertex centre. – Szabolcs Dec 12 '21 at 21:40
  • I suggest you open a feature request and ask for rotation to be implemented. https://github.com/igraph/python-igraph/issues/new/choose – Szabolcs Dec 12 '21 at 21:41

0 Answers0