Ravi Mohan's Tech Blog. To read my non technical blog, click here

Sunday, March 22, 2009

GnuPlot In Action

is a great (e)book. I got the early access version from Manning and it is very well written. Phillip Jaanert has done a great job. I've been using it to visualize the output of some algorithms I've been coding up.

here is a graph I created with GnuPlot for the optimal decisions for different learning rates for 2000 one armed bandits (essentially a stateless value function less precursor to Reinforcement Learning)

4 comments:

Pramod said...

Is GnuPlot better than matplotlib? I've never actually used GnuPlot, but have been using matplotlib a fair amount and I'm quite happy with it. The thing I like about matplotlib is that it uses a real programming language, which can make certain things much easier. That's also the reason why I'd like to avoid GnuPlot if I can. Do you have any comments on this?

Ravi said...

Pramod,

Good Point. I suspect it may all be about the style of use of the plotting/graphing library.

My algorithms are coded in weird languages like Haskell and the data is output into a file, which is then plotted with gnuplot. My clients are not programmers (and so don't want to "program") , but *are* comfortable with gnuplot. This is scenario 1.

In scenario2, *I* (in my "amateur researcher" mode) use the graphs to do data analysis, often by simultaneously displaying and scanning a few dozen plots at the same time on the same data files, looking for patterns. Very often the plotting commands are generated from within the program somewhat like how Martin Fowler uses ruby to wrap ploticus (see http://martinfowler.com/bliki/RubyPloticus.html).

In this scenario, gnuplot seemed a better fit to me than matplotlib. I'd rather generate gnuplot commands than a full python program! (haskell programs generating python programs!)

Besides in this mode of use, I don't need sophisticated graphs, just a few dozen quick and dirty graphs, like the one in the blogpost (which was kind of a "test the haskell/gnuplot interface thing).

I acknowledge this is a subjective preference.
If I were working primarily in Python , I suspect I'd use matplotlib without thinking too much about it.

Pramod said...

My scenario is a hybrid of your two scenarios. I work on a architectural simulator written in C++ which spits out large text files with loads and loads of mostly irrelevant data. Then I have a python script that parses the text file to get the things I want, and then plot them using matplotlib.

The idea of piping generated programs into GnuPlot is fascinating but maybe overkill for my scenario, because you can probably get much of the same functionality by using python's exec statement as a sort of poor man's REPL.

Anyway, thanks for the insightful comments.

Ravi said...

"Then I have a python script that parses the text file to get the things I want, and then plot them using matplotlib."

This is my scenario too with the difference that gnuplot commands don't *feel* like programming to my clients :-)

"you can probably get much of the same functionality by using python's exec statement as a sort of poor man's REPL.
"

I agree. I just don't want to have two libraries depending on whether the guy doing the plotting is a programmer or not :-)

"thanks for the insightful comments."

you are welcome! the pleasure is all mine. finding sensible people to talk to is a rare thing :-D