1

I have data that I want to represent visually. The actual data is a tree made up of nodes. Each node has a bunch of data associated with it, but as far as this question goes, I just want a way to represent a tree visually using Python. Any ideas?

The different solutions that popped in my head were to use a GUI library like WxPython or PyQT, or maybe even a PDF generator like ReportLab. I'm hoping there's a library out there that deals closer with data so that I don't have to think out the plotting locations of all the nodes.

3 Answers 3

6

Not sure if this is applicable to your situation, but have you looked at graphviz? It has decent python bindings for it and I've used it for visualizing dependencies which sometimes end up looking like trees.

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

Comments

2

Instead of using graphviz directly, consider using the visualization tools included in NetworkX. The graph objects there are excellent for many purposes.

Comments

0

Consider using a textual representation of the tree. Otherwise, I'd go with graphviz (dotty, actually).

[root]
+------child1
+------child2
    +-------child3
    +-------child4

To show the same tree in graphviz, put this in a text file:

digraph graphname {
    root -> child1;
    root -> child2;
    child2 -> child3;
    child2 -> child4;
}

Then run dotty on it, or your tool or choice.

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.