[ROOT] Surface Plots

From: Alexander Wagner (a.wagner@physik.uni-wuerzburg.de)
Date: Wed Aug 13 2003 - 09:07:11 MEST


Hi!

Seems my mail from yesterday didn't make it to the list.

Just wondering wether this isn't possible an easier way.
Consider a datafile of the following form:

x1    y1        z1
x1    y2        z2
x1    y3        z3

x2    y1        z4
x2    y2        z5
x2    y3        z6

and so on. This is data for a 3D plot (a surface e.g.; for
me this is 3D for root it seems to be 2D) and the format is
"inspired by GNUplot". Now if I want to have a surface plot
in GNUplot this is actually quite easy:

splot "mydata.dta" using 1:2:3 with lines

giving me a wireframe. Now GNUplot lacks, well, "some"
functionality compared to root and I want to switch over to
root. Unfortunately this simple kind of splot requires me
quite a lot of code compared to the simple GNUplot approach,
and till now I wasn't able to get something "easily
reusable" like the line above. Would be something I'd really
like to have. Some root function returning a TH2D or
something where I can then use stuff like H2D->Draw("surf")
or H2D->Draw("colZ").

Did I miss something really simple?

Seems to be that root already has everything needed, but
always lacking a small part. E.g. I need to know the bining
so a simple approach to just read in the datafile is not
possible without having to calculate this one first. (Though
root has functions to plot a T2F where it knows how to bin
it.) Or I work arround this with quite a bit of code to
count first the bins in each direction and then create a
TH2D using the data counted and read in the file again.
Stuff like that.

It seems to get simpler if I create a root-file first and
use that as input but simple is quite relative compared to
the splot-command mentioned above ;)

For TGraphs the solution is actually pretty simple as I can
add points at the end of the TGraph. But I didn't find a way
to add a new grid point to a TH2D. Seems that a TH2D needs
to know how many points in each direction and which scale
the axis has. So simply reading in the file doesn't work
out. (Though it straight forward specifies each grid "line".)

BTW: I know that root maybe doesn't really target this kind
of data. In fact I use root mainly as a pretty good plotting
program for my Fortran output. But well, it's really good!
Except this nasty splot stuff. And even there root creates
a lot better plots then the other tools I know of. It's just
allways quite complex to do. (In the same direction: reading
in Fortran of the form 1.23456789D-3 isn't that simple.
Maybe it would be a good extension to handle the D as an e
in a future release.)

Thanks in advance for any hints.


-- 

Kind regards,                /                 War is Peace.
                            |            Freedom is Slavery.
Alexander Wagner            |         Ignorance is Strength.
----------------------------|
Theoretische Physik II      | Theory     : G. Orwell, "1984"
Universitaet Wuerzburg     /  In practice:   USA, since 2001



This archive was generated by hypermail 2b29 : Thu Jan 01 2004 - 17:50:14 MET