I am using Networkx to draw a Hierarchy Graph. I would like to rotate the labels to a vertical position, using the rotation keyword seems to have no effect.
nx.draw_networkx_labels(G, pos=lbl_pos, rotation='vertical')
Is it possible to draw the labels with a vertical rotation?
If you capture the output of nx.draw_networkx_labels() you can adjust all of the text parameters. For example,
In [1]: import networkx as nx
In [2]: G = nx.path_graph(4)
In [3]: pos = nx.spring_layout(G)
In [4]: nx.draw_networkx(G,pos,with_labels=False)
In [5]: text = nx.draw_networkx_labels(G,pos)
In [6]: for _,t in text.items():
t.set_rotation('vertical')
...:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With