[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: publication quality graphs



Hi Stuart,

On Thu, 2005-10-13 at 13:57 +1000, Stuart Prescott wrote:

> * current workflow using Origin
> I normally have data from a number of different (but related)
> experiments in the one file (perhaps X1 Y1 X2 Y2 or X Y1 Y2 Y3) format
> that has been exported from OOo.calc or excel or perhaps from a data
> analysis program that I have written for the purpose. The files are
> usually tab-delimited and I can just Import ASCII in Origin and all is
> well. It sets the column names to be the headers from the text file. I
> can then create plots with some or all of the data and will frequently
> want to add new data to a plot from another worksheet trivially etc. In
> the end I produce an EPS graphic for use in LaTeX or a PNG graphic for
> MSWord/MSPowerpoint. I like the "project" paradigm of Origin where data,
> settings and graphs are all together allowing you to add new data to
> plots, plot things in different ways etc. I don't just make the one
> final publication quality graph in an Origin project; rather, I usually
> have several different publication graphs in the one project (and often
> both print and presentation versions of these graphs too) as well as
> other graphs made while I explore the data. I tend not to use Origin for
> data manipulation as it is much more cumbersome than using a proper
> spreadsheet program like excel or OOo calc.

So, you're essentially making plots of pairs of data, or the like? 

> * gnuplot
> I'll confess that I have a deep seated aversion to gnuplot that dates
> back to my undergraduate days which is probably unfair. Having said
> that, I do prefer to be able to manipulate the graphs in real time *and*
> be able to save the settings and data as a project. With gnuplot you can
> do one or other (either run it from a script which is pretending to be a
> "project" file or some sort, or you can do it in real time.)

My initial suggestion would be this, but I can understand were you're
coming from.  I have students that would sympathise with you on this
one :-)

> * others?
> Are there any other utils that you can suggest that might meet my
> requirements? I'm happy to try things out and will post back reviews of
> them too when I have a chance.

ROOT :-) OK, I know that this suggestion was a given coming from me.    

However, in particle, nuclear, and heavy ion Physics we've been using
PAW (Debian package paw) from CERN for many years now.  It's old,
written in Fortran 66 (yes, not Fortran 77, 90, 95 or any of that modern
stuff - good old Fortran :-), and the interface isn't exactly that easy
to deal with.  

The successor of PAW is ROOT (and much more than that too).  ROOT is
essentially a set of C++ classes for doing various things related to
data analysis, storage, GRID (the buzz-word), and so on.   It's used
extensively to prepare all sorts of plots, ranging from the casual plot
to impress your supervisor to plot that are put in articles and books. 

There's a interpreter interface that's useful for plotting stuff, as
well as some GUI tools.   The scripting language is C++.   So, suppose
you have a datafile like 

        # X       Y       	EX      	EY
        0.1     0.000815046     0.012795        0.028549
        0.2     0.00882257      0.0095365       0.0939285
        0.3     0.036713        0.0481904       0.191606
        0.4     0.0596013       0.0191006       0.244134
        0.5     0.176194        0.0305726       0.419755
        
then you could plot this in ROOT with the following script 

        void
        plotit(const char* fname)
        {
           ifstream file(fname);
           TGraphErrors* g = new TGraphErrors;
           g->SetMarkerStyle(20);
           int i = 0;
           while (true) {
             char c = file.peek();
             if (c == '#') { 
                string s;
        	getline(file,s);
                continue;
             }
             double x, y, ex, ey;
             file >> x >> y >> ex >> ey;
             if (file.eof()) break;
             g->SetPoint(i, x, y);
             g->SetPointError(i, ex, ey);
          }
          file.close();
          g->Draw("acp");
        }

To plot the data in `data.dat', do 

        > root 
        Root> .x plotit.C("data.dat")

Titles and the like can be changed either in he script, or interactively
via the GUI.  It's also possible to define preset `styles' e.g., a style
for print, a style for presentations, and so on.    Histograms are
easily made too, and there's a special storage format called Tree's that
has many automatic features. 

You can get the ROOT packages by adding 

	deb http://mirror.phy.bnl.gov/debian-root unstable root 

to your sources.list (see also thread on ROOT in this mailing list). 

> ** conclusions
> The two main things that I can condense out of this are that:
> 
> * there is nothing in linux land that even comes close to Origin for
> flexible scientific graphing and data management. That's a pity... linux
> leads in everything else, but I know very few other people who will put
> the sort of time in that I have done in trying to get this to work.

ROOT's main development platform is GNU/Linux, but it's supported on a
variety of OS's and chips, including MacOSX and Windoze. 

> * the X1 Y1 X2 Y2 data format is a problem.... many of these utilities
> would work better if I wasn't using that. However, dropping that format
> comes at the expense of me having to do a lot more work to split up
> files and then import them individually.

With ROOT, you can use any format you like, as long as you write a tiny
bit of code to deal with it - not a problem.   You can even write your
own extensions and load them dynamically. 

> * generating smooth-curve data is a problem... I'll play around with
> spline(1) from the plotutils package and aspline(1) from the spline
> package to see if that could be a viable filter. But having to filter
> all the data through an external spline program is somewhat suboptimal.
> Perhaps there is python module for this that will work with PyX?

ROOT currently only have simple splines, but I guess that's what you're
after anyway.  Personally, I object to drawing splines between data
points, as it represents an interpolation that often has very little
physics behind it.  One should really try to fit the data if one wants
to draw something from the interpolation. 

> (Note that this is not to say that Origin is without faults. Apart from
> the idealogical reasons for moving to free software, the EPS export in
> Origin6 doesn't clip the data to within the axes which was the final
> motivation for me looking elsewhere. Eventually, I found a workaround
> by printing to a PS file and then using ps2epsi but that's not a great
> solution.)

ROOT exports graphics in all formats supported by libAfterImage - which
is to say, PNG, PS, EPS, PDF, JPG, SVG, and even GIF. 

He, he, so you think I'm a ROOT zealot - well, in some sense you're
right, but I think you'll have a hard time finding something that's more
versatile and useful for numerical data analysis, and the like (that
should provoke a slow of emails :-)  Also, I'm interested in getting
some testers of the ROOT packages :-)

Yours, 

-- 
 ___  |  Christian Holm Christensen 
  |_| |  -------------------------------------------------------------
    | |  Address: Sankt Hansgade 23, 1. th.  Phone:  (+45) 35 35 96 91
     _|           DK-2200 Copenhagen N       Cell:   (+45) 24 61 85 91
    _|            Denmark                    Office: (+45) 353  25 404
 ____|   Email:   cholm@nbi.dk               Web:    www.nbi.dk/~cholm
 | |



Reply to: