Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there an interactive graphing library for python

I'm looking for an interactive graphing library for Python.

By "graph", I meant a set of nodes connected by a set of vertices (not a plot of values over x-y axis, nor a grid of pixels).

By "interactive", I meant I can drag-and-drop the nodes around and I need to be able to click on the nodes/vertices and have the library pass the nodes/vertices to my callbacks, which may add/remove nodes/vertices or display information (I cannot load the full graph at startup as the dataset is too large/complex; instead I'll be loading only the necessary slices of data depending on user inputs).

By Python, I meant the programming language Python, the graphing library should have CPython binding. I have Python 2.7 and Python 3.1, but can downgrade to 2.6 if necessary. This language requirement is because the dataset I'm working with only have Python binding.

The graphing library must support directed graph and be able to layout the nodes automatically. I need to put labels on the nodes.

Preferably, the layouting algorithm should place adjacent nodes near each other. It should be able to handle from 100-1000 nodes and about 300-4000 vertices reasonably in my 4 year old laptop (I typically start with around 100 nodes, but the number might expand depending on user input). Preferably it should be a library with not too many dependencies (except perhaps for Gnome). Open source is preferred.

I have already written a simple prototype of my program using Tkinter Canvas, but I need a more serious graphing library to expand the program. I've looked at graphviz and matplotlib, but apparently they're only for working with static graphs and apparently would need significant amount of work to do interactive manipulations (correct me if I'm wrong, I've only looked at them briefly). I've also tried generating the graph to an SVG file and using Inkscape to view it, but it's too slow and takes too much memory and because of the sheer number of vertices it becomes a tangled mess.

like image 655
Lie Ryan Avatar asked Apr 22 '11 20:04

Lie Ryan


People also ask

Can you make interactive plots in Python?

Overall, if you are getting started with interactive plots using Python, Plotly can be a good choice to create simple plots with limited interactive components. But if you are looking to add a number of interactive components to your plots, then Altair is something you should really try your hands on.

What is the best library for plotting in Python?

matplotlib. matplotlib is the O.G. of Python data visualization libraries. Despite being over a decade old, it's still the most widely used library for plotting in the Python community.

Which Python libraries can be used to plot real time interactive graphs?

Seaborn. Seaborn is a great visualization library in Python used for plotting statistical models and complex relations among data. It can plot complex plots like Heatmaps, Relational Plots, Categorical Plots, Regression Plots, etc. Seaborn made complex data analysis and visualization easy and simple to execute.


1 Answers

Looks like Nodebox might be what you want:

http://nodebox.net/code/index.php/Graph Mac OSX

http://www.cityinabottle.org/nodebox/ Windows (using OpenGL)

Nodebox screenshot

The graph object has functionality for mouse interaction as well, bundled in the graph.events object. It has the following properties:

  • graph.events.hovered: None or the node over which the mouse hovers.
  • graph.events.pressed: None or the node on which the mouse is pressing down.
  • graph.events.dragged: None or the node being dragged.
  • graph.events.clicked: None or the last node clicked.
  • graph.events.popup: when True, will display a popup window over the hovered node.

Also came accross Gephi, looks like that might have the functionality you want as well.

http://gephi.org/ Windows, Linux and Mac OSX

Gephi is an interactive visualization and exploration platform for all kinds of networks and complex systems, dynamic and hierarchical graphs.

gephi screenshot

like image 131
Acorn Avatar answered Oct 04 '22 04:10

Acorn