Plotters Part IV

October 17, 2010

Too depressed about the pending university cuts to write about that yet. Instead lets have fun ! Yes, lets do the fourth and the final part of the rambling Norse Epic that is my series of posts on plotting software.

Just to bring you back up to speed… First there was a general intro. Next up, Part II was about mathematical environments, plot libraries, and equation graphers. This brought out the R fanboys. Part III was about GUI based plotters, wherein I gave healthy plugs to mjograph and the bizarrely named but handy Veusz. In today’s installment I will look at script based plotters.

Sometimes a GUI based application just doesn’t have enough flexibility, and all that clicking is too laborious. On the other hand, pernickety calls to low level routines inside a C programme is just overkill, especially if you already have the data file from somewhere else. A nice little script language is what you want, with sensible defaults, so you can just say plot sin(x)/x and leave it that, or you can gradually add sophistication, setting the axes, line weights, etc, saving the script and fiddling more later.

MONGO and her seed. For astronomers at least, the Mother Of All Plotters is Mongo, written by John Tonry in the 1980s. (Yes, that is the same John Tonry who made the vast camera for PanSTARRS ). It was written in F77, and routines can be called from Fortran programmes as well as run interactively. I think the last version was in 1994, and I don’t think you can get it now, but you can still get the documentation here.

The equally legendary Robert Lupton and Patricia Monger re-implemented Mongo from scratch with added bells and whistles as “Supermongo” or SM. It is available here, and there is a kind of forum-cum-fansite here. It costs $300 for a single Department-wide license but is “not available for military use”.  Back in the Yookay, the Starlink project also re-imagined MONGO. (Can’t stop thinking of Pierre Menard.)  This was called PONGO as the backend was the PGPLOT library. The Starlink project is no more, but the whole suite is maintained and still available via the Joint Astronomy Centre in Hawaii. You have to download the entire rather vast Starlink installation, but you will also get other useful things like Gaia, SPLAT, and ORAC-DR.

There have been other front ends for PGPLOT. Two I am aware of are WIP , written for the  Owens Valley BIMA array project, and  QDP, meaning “Quick and Dandy Plotter”, written by Allyn Tennant at Marshall Space Flight Centre. Finally there is Pyx. This is an implementation of PGPLOT in Python, which can then be strung together in a Python script, but it doesn’t have the simple syntax of SM or Gnuplot. Pyx begat Pyxplot, as we will see below, but in a manner that never occurs in nature, it replaced the genome while keeping the same phenome. Ain’t software fun.

Trusty Gnuplot. Outside the astronomy world, what most people know is  Gnuplot, started in 1986 by Thomas Williams and Colin Kelley, and continously developed and improved since by an army of volunteers. It has a slightly quirky syntax, but is easy to get used to. In interactive mode it has sensible defaults, so you can just fire up and plot a function or a data file with very little fuss, but it is also very powerful and flexible – for example you can plot arbitrary algebraic combinations of columns, plot parametric functions, and fit datasets. You can define constants and functions, and you can keep your own library of these which you load at startup. For example, I have a standard blackbody function, and then in a new script I can just refer to RBB(nu,T). This also means that in interactive mode you can use Gnuplot as a calculator, and some days I prefer this to Python. It does pretty much everything you need with some minor niggles – for example in SM you can use a column to record a different point type for each data point, whereas in Gnuplot you would have to achieve this by dividing into blocks and using several plot commands.  Although the point of Gnuplot is scripting, just to confuse you, you can get a GUI front end to Gnuplot – here is a Mac example. This isn’t quite as daft as it sounds – its a handy way of reminding yourself of options, and can be quicker than looking things up in the manual.

Gri. An alternative to Gnuplot is  Gri, written by Dan Kelley and Peter Galbraith. Its syntax is slightly friendlier than Gnuplot. I have only done a quick test drive, but it looks like its not quite as flexible and powerful as Gnuplot. For example, it doesn’t do parametric plots or curve fitting, and plotting functions is rather more awkward.  It does maths RPN style, so John Peacock should love it, but for most folk thats an annoyance. I found it harder to get really nice looking output than with Gnuplot. So I probably won’t swap to Gri. But if there are fans out there, do tell me I’m wrong !

Pyxplot. So now we come to this week’s main plug,  Pyxplot . This was written by Dominic Ford, with help from others. Dominic is a PDRA at the Cavendish in Cambridge, whereas Jeremy Sanders who gave us Veusz is at IOA, so I expect there’s no rivalry there then … Methinks there should be another plotting package by the People’s Front of Judaea. Err.. anyway, where was I ?

Pyxplot is a kind of re-invention of Gnuplot (there goes Pierre Menard again), with almost identical commands and syntax. Originally, it was written in Python, using the Pyx library, but the latest version has been completely re-written in C++, for speed and reliability reasons. If you use Gnuplot, you can get straight down and use Pyxplot, and re-use your scripts with minimal changes. However, Dominic has taken the opportunity to add some rather groovy stuff, mostly in its mathematical environment. Some of the extra things Pyxplot can do :

  • annotate in TeX
  • convert physical units
  • do calculations with complex numbers
  • evaluate integrals
  • find minima and maxima
  • solve simultaneous equations
  • use pre-supplied list of physical constants – hbar etc
  • read FITS tables
  • load data from a URL
  • output a sampled function as a datafile
  • Fourier transform data files
  • output a histogram from a column of data
  • generate random numbers
  • use programming logic, like for loops, conditionals, and subroutines
  • plot 2D data as a surface or as a colour map

Plotting parametric functions is easier than in Gnuplot. I think the control of plots and styles and so forth is even more thorough than Gnuplot, but I can’t say I have crosschecked everything.  One possible drawback is that it still has some performance issues – some of my Gnuplot scripts run distinctly slower than in Gnuplot. But overall it is pretty amazing and I do recommend giving it a go.

Here ends the Saga. Unless I add another chapter where Robert Lupton goes baresark in Princeton and Jeremy leads a raiding party to the Cavendish and steals Dominic’s women.

Advertisements

Plotters Part III

October 10, 2010

Geek Week now resumes. Last week I started some burblings about plotting. Apologies for those who find this dull. Getting it off me chest.

Part I was a general intro. Part II was about mathematical environments, plot libraries, and equation graphers. Now I will launch into GUI based plotters.

There is a whole bunch of these, including things you pay for like Datagraph and ByeGraph, and some free things like Grace, Plot, SciDavis, and Hippodraw. Most but not all of these are multi-platform. They all have various strengths, but a common weakness – they are incredibly intimidating, with gazillions of windows, buttons, sliders, and options. It may well be that if you get used to one of these, they are just what you want; if that’s true for one my readers, let us know. But my own vote goes to two applications that I find much more intuitive and simple. What they have in common is that the complexity is hidden until you need it, which is made possible by the way they think of graphs as made up of a hierarchy of components, each of which can have its own settings – page, graph, x/y-axis, curve, dataset.

Mjograph. My first plug is for mjograph written by Makoto Tanahashi, a PhD student from Yokohama. Its a Java application, so it should work fine anywhere. It has a clean simple interface. It can plot multiple functions and multiple datafiles, listed as objects, so you can pick each one at a time and set its properties – point size, colour, line weight, etc. The adjustment of appearance, including annotation in TeX, is clean and simple but effective.  (I spotted one or two bugs though…) The approach to datafiles is also simple. It expects plain text files with x,y, and error columns in various allowed permutations. You just drag the file onto the window and it gets plotted. Weaknesses are that it doesn’t do parametric functions, and doesn’t do column manipulation (“plot column 3 as X, and the sum of columns 8 and 11 as y”) but really if you want that sort of thing you should probably use a scripting package like Gnuplot.

Veusz. The second plug is for Veusz written by Jeremy Sanders, a PDRA  at the Institute of Astronomy in Cambridge. This is written in Python, but is available wrapped up as a Windows, Mac or Linux app. Apparently VEUSZ is pronounced “Views” and stands for Velvet Ember Under Sky Zenith, for no particular reason. And why not. Veusz can do function plots, data files, and fits to data files. Like mjograph, it has a nice logical hierarchical approach to editing the properties of various objects, and its quite easy to adjust line weights, annotate in TeX, colour things in, etc. The various editing windows can float free or be tiled, but getting them back in place drove me bananas… Data can be edited in by hand, or imported from plain text, csv, and FITS. You can only import one dataset at a time though (I think).  Veusz can do contours, vector fields, and and grayscale images, but it doesn’t do surface plots. You can’t plot a parametric function, but in the dataset editor you can create a dataset with a parametric function.You can also do column arithmetic to make new datasets. So it can do rather more than mjograph, but of course at the cost of just a little more complexity.

The really nice thing is that it is scriptable as well. Every GUI action has a corresponding Python command. The app comes with a console which is a Python window, with numpy already loaded. You can use this in a normal Pythonish way, but you can also issue Veusz commands or run a whole Veusz script. That nice Dr Sanders also provides callable libraries for C and C++, and says a Fortran library is on the way.  When you save a plot you have been working on, its actually a text file containing the Python commands, so you can edit this, and teach yourself the scripting version. Below is a plot I just made with the GUI, and its script equivalent. (Note mistake : “bump” should be “dip”). As you can see, its perfectly logical, but kinda laborious. So this is really nice, but I don’t see it as a replacement for Gnuplot or similar.

Link to the Veusz script to produce the above plot.

Topcat. Finally, a plug for good ole Topcat. If you are interested in tabular data, rather than functions, and want to explore the data rather than making fancy plots, then this is what you want. Where bees are concerned, it is the knees.


Plotters Part II

October 7, 2010

Yesterday I started some ramblings about plotters. I am sorry to disappoint Alex who was looking foward to hearing about devious schemers. Instead, we have some brief thoughts about mathematical environments, plot libraries, and equation graphers. Tomorrow(ish) will be GUI apps.

Mathematical Environments. Many folk swear by gargantuan packages that provide a programming environment, algorithm libraries, graphics utilities, algebraic manipulation, and so on. Popular packages include IDL, Matlab, Maple and Mathematica . These are very powerful, but with a bit of a learning curve, and of course they all cost lots of dosh. The only free, open source, alternative I am aware of that tries to be a complete Matlab-like replacement is Sage. I haven’t tried this out myself, and would be interested to hear of experiences. The other thing worth mentioning is R which started life as a statistics package and seems to have ballooned into an all-singing all-dancing kind of thing. It has some fans, who have emerged in my recent comment stream, but I haven’t tried it yet. Well, I started trying to read some documentation and nearly lost the will to live.

Plot Libraries. For astronomers at least, the grandaddy is PGPlot, started in 1983 by Tim Pearson and still in everyday use by lots of people. The latest version is 5.2.2 from 2001. It is a library of primitive routines, callable in Fortran or C. Several people have written interactive front ends – WIP, PONGO, and QDP (see Part IV).  PLplot is intended as an updated version of PGPLOT. It has bindings to a very wide range languages, including C, Fortran, Python, Perl, Java, C++, and several others. If Java is your thing, you might also want to look at JFreeChart. If Python is your thing you might want Pyx. It has high level things as well as primitives, and because Python has an interactive mode, you can use it in somewhat the manner you might use Gnuplot. However, as you can see from this example it is distinctly less streamlined and friendly than Gnuplot. Matplotlib is another Python library with both primitives and high level stuff, and ambitions to be a complete environment, a la Matlab. It looks good, but I couldn’t make it work…  There are links to lots more Pythonesque bits and pieces here. So if you want to include plotting in your own programs, there is a lot of choice, but it looks to me like the standard choice these days is PLplot .

Equation Graphers. If all you want is a quick plot of a mathematical function, you can do with this with Gnuplot and cousins, but you are likely to want to explore it – pan and zoom, read out values. In this case an interactive GUI style application makes sense. On the Mac you have this pre-loaded with Grapher, which started life as Graphing Calculator, still independently available here for Mac and Windows. If you want an entertaining hour, you can listen to Ron Avitzur telling the strange story of this application. (There is also a written version of this story.) For Linux folk, there is the wonderfully easy Lybniz – why isn’t there a Macports version ? Another nice lightweight free MacApp is Edengraph but it can’t do some things that Grapher can – like 3D functions, vector fields, independent axis adjustment. Two fairly glitzy commercial applications are A&G Equation Grapher, its cousin Graphing Calculator 3D and Golden Software Grapher. Graphing Calculator 3D has a free version.

Enough for now. Part III will be about GUI-style plotting applications.


Plotters that do what you want

October 6, 2010

I have finally written up my thoughts on plotting packages, but its a bit long .. so I am going to do it in installments …


Just over a year ago I wrote a couple of posts (here and here) about looking for calculators that hit a sweet spot between laborious button-pushing GUI and full blown programming – something where you just type calculations, bring them back and edit them, save a few named variables and constants, maybe a few basic user-defined functions.  I ended up sticking with Python, but also found Gnuplot to be excellent for this purpose. I also really liked two Mac apps – PEMDAS and Speedcrunch –  that cleverly combine GUI and plain command line window interfaces. (Speedcrunch is available for Windows and Linux too.) These were both really nice but had significant gaps, being at an early stage of development. I had hoped by now that they would have progressed significantly, but in fact over a year later they still seem to be at the same version numbers – 0.2.4 and 0.10.1 respectively. (Speedcrunch has a version 0.11 alpha, but still no function definition…) I hope they get a kick start soon.

 

So what about scientific plotters ? There is a similar choice. You can cook your own, by using libraries of routines inside your own C programs etc, or you can go for a button driven GUI. But the former is often overkill, and the latter tends to be awfully laborious. What you really want most of the time is just a window where you can type “plot sin(x)/x” or whatever, or “read datafile” and “plot col2 vs col6″ etc. Then you can tart up the plot as much as you like with commands that set xmin and xmax, number of ticks etc. And finally of course you save all these commands in a script you can run and edit. So now all the oldies are saying “thats MONGO, man” and the kids are saying “thats Gnuplot, dude”. But after searching the interweb for a while I found some other really interesting possibilities. I am pleased to tell you that my two favourites are both written by Cambridge astronomers – Veusz and Pyxplot. Must be something they put in the East Anglian water. But lets work up towards these. Its going to be helpful to break this into sections :

  1. Mathematical Environments
  2. Plot Libraries
  3. Equation Graphers
  4. GUI plotters
  5. Script plotters

Tomorrow I will have a brief look at parts 1-3, and then a slightly more extensive look at parts 4 and 5 on following days (note vagueness regarding interval..)