Plotters Part III

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.

10 Responses to Plotters Part III

  1. Thanks for the Veusz review.

    For the standard import you can import more than one dataset at a time. The standard way is have them in columns (like x, y, z…). Also, if you tick the “Read data in blocks” option then if you leave blank lines between sets of data you’ll end up with numbered datasets, e.g. x_1, y_1, x_2… Finally you can also place “descriptor” statements in your datafile to tell veusz to start new datasets, e.g.

    descriptor x y
    1 2
    3 4
    descriptor z +-
    6 0.1
    7 0.2

    Which will read x, y and z (z has symmetric error bars).

    The CSV import option also lets you have multiple datasets in a CSV file (just put a new name above a column of numbers).

    For the column manipulation, there is a new feature under the Data->Compute menu. You can create new datasets based on existing datasets there (add, subtract, multiply, etc), which tries to work out the correct error bars. They will update when the data are reloaded from the input file. You can also use general expressions in the “Data->Create” dialog box, selecting “Expression using existing datasets”.

    The saved file formats are kind of laborious, but you can make it a lot shorter if you are doing it by hand. There’s a new object oriented interface which can be accessed in the scripts, as a python module or from the command line. See http://barmag.net/veusz-wiki/EmbeddingPython


    import veusz.embed as veusz
    import time

    embed = veusz.Embedded('window title')
    page = embed.Root.Add('page')
    graph = page.Add('graph')
    function = graph.Add('function', function='x**2')

    time.sleep(2)
    function.function.val = 'x**3'

    Unfortunately there is not C/C++/Fortran interface, but you can send Veusz commands to veusz_listen, which will bring up a plot in a window.

  2. andyxl says:

    Jeremy – sorry I didn’t spell this out to readers, but I do realise that you can put more than dataset in a single file, either using different columns, or using datablocks, just like you can in Gnuplot. What I mean’t was you can’t import from more than one file. You might store datasets-1,2,3 in files A,B,C. Then on Tuesday you want to make a plot with A and B comparing to some function. Then on Wednesday you want to make a plot with A and C comparing to some other function. Ideally, you don’t want to keep making special purpose conglomerated files for each purpose. You want a library of datasets and to plot them as you want. Maybe you want to plot 6 different quasar SEDs from a collection of 113.

  3. You can read the data from more than one file. Just read dataset A from file 1, B from file 2, C from file 3. They should all appear in the Data->Edit dialog box. Am I missing something?

    You can also set the prefix/suffix in the import dialog box to $FILENAME to get the filename to be prepended/appended to dataset names.

    Veusz doesn’t automate reading from 100 files, but you can do this in the command line window:

    for i in xrange(100):
    ImportFile('data_%i.dat' % i, 'ds_%i' % i, linked=True)

    To read ds_X from data_X.dat where X goes from 0 to 99.

    Hope this helps! (sorry if I’m being dense)

  4. andyxl says:

    Probably me that missed the trick.. I will try it out later

  5. Alexander says:

    Hello!
    Did you tried MagicPlot for plotting? 🙂 Maybe it can also be useful. And it is multi-platform (Java, as MjoGraph).

  6. andyxl says:

    Looks interesting – will definitely give it a go

  7. Alexander says:

    Thank you!
    It would be great if you wrote you opinion about MagicPlot (here or in private message). It is relatively new application and the development is in progress.

  8. Sillas y mesas de comedor…

    […]Plotters Part III « The e-Astronomer[…]…

  9. Mesas de comedor…

    […]Plotters Part III « The e-Astronomer[…]…

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: