[Solved] Different Problems with TGraph, TAxis

Hello everybody!

Prologue:
I wrote a small simple code which is intended to be a MC simulation in the future. At the current state, the MC sampling is not implemented yet, because of its alpha role, you can find it in the attachment. As you can see, I create a canvas and I plot and save different graphs with a while loop. Next, I glue the snapshots with ffmpeg and get a movie, CppMovie.avi which you also find attached in two different version in the archive CppMovies.tar in order to show the problems.

Questions:

  1. If I do not use TGraph::SetTitle(""), the snapshots get a name I did not defined in the canvas constructor. You can check that in CppMovie1.avi. I am wondering why. Interesting fact, the name “Graph” is the same of a canvas I created in another code weeks ago, but then I don’t understand why the two canvas are related.

2)If you look carefully at CppMovie1.avi, you see that both X and Y axis are moving. Now, I know there is a way to specify X and Y range but using the command TAxis::SetLimits(double, double) does not work for Y axis in my code.

Summing up
CppMovie1.avi: “Graph” name issue, axis range
CppMovie2.avi: name issue solved with SetTitle(), X axis fixed, Y axis floating

Any suggestion?

Also, If is possible, I would like to know if I can improve ROOT stuff I did in the code, for example I declared Double_t arrays and then I filled them with values from vector, or all the conversion I did…was all this necessary or is there a smarter way?

I compile in this way, on an x86_64 architecture, Fedora Linux, ROOT 5.28/00c with fixed installation, gcc 4.5.1, don’t know if matters

[code] g++ -Wall -I/home/Guido/root/include -c PBC2.cpp

g++ -O2 -m64 PBC2.o -L/home/Guido/root/lib -lCore -lCint -lRIO -lNet -lHist -lGraf -lGraf3d -lGpad -lTree -lRint -lPostscript -lMatrix -lPhysics -lMathCore -lThread -pthread -lm -ldl -rdynamic -o PBC2.exe
[/code]
BTW: why .avi format is not allowed!!!

Thanks for helping and sorry for the long post,
G.
CppMovies.tar (1.05 MB)
PBC2.cpp (4.76 KB)

TGraph is a low level object used by others objects like the histograms. The constructors do not allow to set the title. A default title “Graph” is set. To change the title use SetTitle (as you did).

2)If you look carefully at CppMovie1.avi, you see that both X and Y axis are moving. Now, I know there is a way to specify X and Y range but using the command TAxis::SetLimits(double, double) does not work for Y axis in my code.

See root.cern.ch/drupal/content/how-set-ranges-axis

Worked, thank you very much. Still wondering why there is such a discrimination between X and Y axis (!). Any suggestion regarding the ROOT code “optimization”?

Cheers,
G.

What you are doing looks fine seems to me.