Dyamic rendering of graph API for python - python

I wish to find a library which is able to render the evolution of a graph during the processing phase. Therefore you would be able to see the graph visually growing and/or pruned according to the current results processed by the classes. Is there any library for python which has the following requirements?

Assuming you are talking about a changing dataset (as opposed to the graph-theoretic type) matplotlib can do this. The documentation for the animation functionality is lengthy, but there are many examples at:
http://matplotlib.org/examples/animation/
If you are talking about the other type of a "graph", you can use networkx to manipulate and render the graph with fixed positions. Underneath it uses matplotlib as its drawing backend.

Related

Python interactive graphs library

I'm writing a software in Python for graphs creation and visualization. I can't find a graphic library to use (in addition to PyQt) to display a graph (different types of nodes with edges) and let the user modify it by adding and deleting nodes and edges. The idea is to manage graphs in a similar way to Dia, for example.

Analyze graph using Python Library or create graph using matplotlib

I have got graph which need to analyzed and report an Error.As of Now I had a data in Excel data.So I have used xlsxwriter to Create graph.But I need to analyze graph.
1.Solid red line was created using xlsxwriter using excel data and was very easy to implement.
In later Enhancement,
2.In Ideal condition,The formula provided to us, we will have dotted red line. So we need to determine difference and report an error.
So First approach was, write a data in Excel sheet using formula and compare data into Excel sheet and report an error.
But we also need to represent into graph also and we will have upcoming task also in which we require graph (basically 2D and line graph) I have googled and found matplotlib which generally use for create graph. So I have very basic question,
Can anyone suggest me library which can be used for this scenario. it will be great if I have input any standard graph library(cover Line grpah) So I can put effort to familiarize with them. it will save lot of effort of us. we generally create graph for circuit analysis.
Language : Python
Environment : Linux
Library : Should be open source
I know, it is very open ended question.But I thought Let have a opinion who has used graph in Python
or is it possible to create below like diagram using matplotlib

Matplotlib figure changes for publication after making the figure

I have been running into the problem of generating publication 'perfect' images in Matplotlib (i.e changing the fontsize, marker size, figuresize, number of ticks etc...).
Essentially, I want to do what is described here: http://www.scipy.org/Cookbook/Matplotlib/LaTeX_Examples except after the figure has already been made. i.e I want to make a function that accepts the Figure object, and makes all the necessary changes, some of which are available as input arguments. That way I don't have to always modify my scripts when I decide to use a figure in a paper.
Is there an efficient way to achieve this?
Note I'm usually using Ipython.
Well, we are doing this all the time to create good figures. In our case we wanted something that would automatically choose the linestyle and marker because we always have to plot many lines in the same figure, and this would avoid manually specifying these things.
We programmed some functions so that at the end you need a plot.py script, which is very simple, and an input.txt with all the info. In the input file you can also use any parameter like linewidth, label, and so forth.... but by default it will follow the pre-defined order for linestyles, markers and so on.
Also, you need a good matplotlibrc file. You can have many different matplotlibrc files since the highest priority is given to the one at the local directory, as explained here. This will allow you to customize keeping your plotting code cleaner.
The functions commented above (with examples) are available in this link, maybe they can give you some insights.
They solved one problem I had with subplots, described here.
Maybe you can make use of matplotlib pickling available in vs 1.2.1.
As said in the above link:
Philip Elson added an experimental feature to make figures picklable
for quick and easy short-term storage of plots. Pickle files are not
designed for long term storage, are unsupported when restoring a
pickle saved in another matplotlib version and are insecure when
restoring a pickle from an untrusted source. Having said this, they
are useful for short term storage for later modification inside
matplotlib.
No personal experience, however

real time gui for python using only traits

Is it possible to create a ui using traits from python to make an interface for a cellular automata simulation?
Of course, you can do anything with Traits that can with Python!
Seriously though, I presume your question is really about generating a GUI in which to display the CA. In that case I can recommend Mayavi which is based on Traits. It has a surf function which plots an array of regularly-spaced data as a 3D surface. There are docs on animating the data which shows how to change the underlying surface data for very fast rendering, which I have used and works well. I have a 3D numpy array shape=(x,y,time) and then for each step I pass a slice to surface objects data object:
surf.mlab_source.scalars = array[:,:,timepoint_index]
Alternatively you could use Matplotlib's imshow for a 2D plot of the same data. There is a very good tutorial on embedding matplotlib in traits.
One issue with using these large libraries (which themselves have many, many dependencies) is being able to distribute your application along with the libraries. I have successfully frozen a Mayavi/matplotlib/traits app on Mac using py2app and Windows using py2exe, starting from the Enthought Python Distribution, but it wasn't easy. However, if you just need it to work on your computer and generate results then both of these approaches will save you time over writing a graphics system for your cellular automata.
Having said all that I also hear good things about GarlicSim (as cool-RR mentioned), which would seem to be custom-made for your purpose.
Can't post links because this is my first post, I will add them later.

Best python UI package for simple graph simulations (TSP simulation, etc...)

I've never done any UI programming in python before. What is the best (read most intuitive, easy to use, functional) UI package for python for doing simulations?
I'll be doing a simulation of TSP right now. So I'll have a graph (nodes and edges) where the edges are rapidly changing, along with some selection boxes to choose different styles of the algorithm, choose the number of nodes, etc..
I've already written this code with a command line interface and I'm hoping for something pretty seamless to port in a gui :)
I am not sure what you mean by "simulations" since the type of UI you want to do depends on what you simulate. But if you want to visualize graphs, networkx is pretty cool.
Such a simulation could be easily coded using:
networkx - for the graph data structures and algorithms
matplotlib - which is used by networkx to visualize graphs
Some GUI framework - PyQt, for instance, for the display and interaction with the user
What's cool is that these can be learned and tried separately. networkx is very powerful and can provide anything you need graph-vise. It works well with matplotlib, and you can show the steps of TSP by different colorings of edges/nodes. matplotlib can also be easily integrated with PyQt to put it all into a single interactive program.
Colleagues of mine are working on a similar-sounding setup to you - they use http://matplotlib.sourceforge.net/ and PyQt - PyQt can add a matplotlib object easily as a widget so the two integrate very well. A tutorial for PyQt is available here: http://www.zetcode.com/tutorials/pyqt4/
If you have graphs, you should definitely check out PyGraphviz (the interface is pretty similar to the aforementioned networkx)

Categories