Hi all,
I’m new in Root and maybe my question looks like stupid, but…I’m trying to fill a 2D Graph by reading a data file, with the command:
Just to test it, I wrote the following graph2.dat file by using NotePad (I’m working with Windows XP):
3.3 4.1 5.0
4.2 3.8 5.0
5.1 6.7 5.0
6.3 2.4 5.0
7.6 8.9 5.0
5.5 3.0 5.0
I put the file and the macro in the same folder.
When I run the macro, I get the following message:
"Cannot open file: graph2.dat, TGraph2D is Zombie, Empty TGraph2D"
I just tried with the latest ROOT version on both linux and Windows and it is fine for me. This code has note change since a long time so it should work also with older versions. Which version are you using ?
I’m using Version 5.15/08. I enclose to this post the code and the data file (I changed file extension from “dat” to “txt” just to send it to you, that could help you in understanding my mistake!
thanks!!! graph2.txt (78 Bytes) provaGraph2D_v0.C (368 Bytes)
Are you telling me that I cannot have any blank lines even in the code?
Anyway, I suppressed any blank line from both, the code and the data file…but still the same error message (here attached)
I was telling that your files have a CTRL-M character at the end of each lines. Blank lines are fine. I executed again your example the same way as you did on XP. See attached file. It is still ok.
I put the data file in the root/bin (where root.exe is) or in the root/tutorials (where my code is) folders…now I put in the C:\root folder and it is fine.
My query was relevant to this query. My data file has 4 columns and I wish to draw surface using cols 1:2:4. The columns are in the format “int float float float”.
Just using the code
TGraph2D *g1 = new TGraph2D("PsiSq.dat");
does not serve the purpose.
I tried to use
TGraph2D *g1 = new TGraph2D("PsiSq.dat","%lg %lg %lg %lg");
which crashed the root.
I want to avoid simple reading the file line after line and making the variable vector just to make job simpler.
I have seen those pages. In those cases, data file has 3 columns and all are used to plot surface plot.
In my case, data file has 4 columns and I want to plot surface using any three of those 4 columns. In GnuPlot I may use something like “splot “filename” u 1:3:4 wpm3d”. I am confused how can I address any three columns for surface plotting in Root. I do not need histogram or error plot.