0

I have been using the pydot project to generate graphs showing relations between different data.

import pydot 

graph = pydot.Dot(graph_type='graph') 

for i in range(3):
 edge = pydot.Edge("Root", "Connection%d" % i)
 graph.add_edge(edge)

conn_num = 0
for i in range(3):
 for j in range(2):
  edge = pydot.Edge("Connection%d" % i, "Sub-connection%d" % conn_num)
  graph.add_edge(edge)
  conn_num  += 1

graph.write_png('graph.png')

Running the above code (taken from here) gives me: enter image description here

Question

Is there any way pydot can be configured to work in real time or are there any similar projects like pydot which allow to make graphs in real time? Something which will allow me to add new edges as the data arrives.

2
  • How do you want to see the graphs? You can just make a new png file each time. Commented Mar 12, 2015 at 14:50
  • Yes I can but I just want one file which gets dynamically updated and displayed as new data arrives Commented Mar 12, 2015 at 15:06

1 Answer 1

1

Networkx is a python module that specializes in graphs. For visualization, it uses matplotlib.

in matplotlib you can either clear and re-draw the image, or use the animation functions. Clearing and re-drawing is trivial to code. I haven't used the animation functions, but I would expect faster/prettier results, at the cost of more complex code.

Example of a networkx usage: how to draw directed graphs using networkx in python? (or you could use the actual documentation: https://networkx.github.io/)

matplotlib up-date question on SE: Dynamically updating plot in matplotlib

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.