0

Long sentences are cut off and not visible. How to set networkx line length? I tried set figure size. But The length of the line was increased together. my image:
my image `

import matplotlib.pyplot as plt
import networkx as nx

graph = nx.Graph()
graph.add_nodes_from(('looooooooooooongtext','shorttext','asdasdasd',4,5))
graph.add_edges_from([('looooooooooooongtext','shorttext'), ('looooooooooooongtext','asdasdasd'),('looooooooooooongtext',5),('asdasdasd',5)])
graph.add_edge('looooooooooooongtext',4,weight=1)
plt.figure('result',figsize=(10,10))
nx.draw_circular(graph, with_labels=True,node_size=80,font_size=10)
plt.show()

`

eyllanesc
  • 221,139
  • 17
  • 121
  • 189
  • Take a look at this recent question: https://stackoverflow.com/questions/64798027/networkx-label-being-cutoff. `plt.margins(x=0.4)` should increase the space for the labels – Sparky05 Nov 14 '20 at 11:34
  • This answer was of great help to me. I didn't know there was a way to do this!! Thanks :) – present Park Nov 15 '20 at 05:37
  • Something you can add to that concept is to add newline characters "\n" at certain intervals in your node names. It would be a two step operation to split the node names at constant intervals as answered here https://stackoverflow.com/questions/9475241/split-string-every-nth-character . Then you can join the resulting lists by the "\n" character – cookesd Nov 15 '20 at 18:43

0 Answers0