TGraph Point Label

Hi Everybody,
I wanted to know if it is possible in TGraph to show a label near a point with the indication of its quote. If anybody can help me I thank him a lot!
Bye

Pietro

Assuming a TGraph* gr object, you can add an annotation object ,eg TText, TLatex, TPaveLabel, etc corresponding to a point in the graph with something like:

TLatex *latex = new TLatex(gr->GetX()[5], gr->GetY()[5],"my annotation"); gr->GetListOfFunctions()->Add(latex); gr->Draw("alp");
It writes an annotation (left adjusted) at the 6-th point of the graph.
You can set the normal graphics attributes for the annotation, eg

latex->SetTextSize(0.07); latex->SetTextColor(kRed);
When drawing the graph, the annotation (or annotations) will be automatically drawn.
If you write the graph to a file, the annotation(s) will also be written.

Rene

Thank you very much!

Pietro

the line

graf->GetListOfFunctions()->Add(latex);

give me an error

Error: illegal pointer to class object GetListOfFunctions() 0x0 14 graph.C:145:
*** Interpreter error recovered ***

How can I manage to solve the problem?

Thank you

Pietro

Could you send the shortest possible running script reproducing the problem? In case you run with an old version, upgrade your version first.

Rene

g[i] is an int array
c[i] is a TCanvas* array
pp is a TCanvas*
x and y are double arrays

[code]for(int i=0;i<6;i++){
if(g[i]<0)continue;
pp=c[i];
pp->cd();

TGraph *graf = new TGraph();
int aus=0;
for(int j=g[i];j<N;j++){
	double div, actq, usl;
	int aus2=g[i];
	int att=0;
	if(aus==0){while(1>0){div=y[aus2];
		   	      if(fabs(div)>.00000001)break;
			      aus2--;
			      att++;
			      }
		   }
	if(att!=0 && j==g[i]){actq=(y[aus2]/div);}
	else{actq=(y[j]/div);}
	if(fabs(actq)<.0000000001)graf->GetPoint(aus-1,usl,actq);
	graf->SetPoint(aus,x[j],actq);
	aus++;
	}
TLatex *latex = new TLatex(graf->GetX()[4],graf->GetY()[4],"pippo");
graf->GetListOfFunctions()->Add(latex);[/code]

I’m using ROOT Version 5.12/00 July 06.
Thank You

Bye
Pietro[/code]

Replace the line

TGraph *graf = new TGraph(); by

TGraph *graf = new TGraph(0); or better

TGraph *graf = new TGraph(N);
Rene

Thanks

Pietro