The code for the Postscript and SetXTitle script

Matthias Vitt (vitt@imt.fzk.de)
Wed, 19 Feb 1997 12:37:43 +0100


Hi Rene,

Well, Surely I put "TPostScript" as class identifier in this script, since
without I must have gotten an error. The file fff.ps is printed but not in
8 cm x8 cm. It is still the default size. The Fit is done without any problems,
but I still get the "illelgal pointer to class GetHistogram()" error when I
try to set the x-axis title.

So here's the code. It is bascically the tutorial graph.C. Maybe you find a gross error. (better hopefully you find
one , I really want to use root). Off course there is the possibility to set
an axis title via a PaveText-object. But the other way would be more satisfying.

Thank you very much for your help.

Mats

{
gROOT->Reset();

c1 = new TCanvas("c1","A Simple Graph Example",200,10,700,500);

c1->SetFillColor(42);
c1->SetGridx();
c1->SetGridy();
c1->GetFrame()->SetFillColor(21);
c1->GetFrame()->SetBorderSize(12);

Int_t n = 8;
Float_t x[n], y[n];

for (Int_t i=0;i<n;i++) {
x[i] = i*0.5;
y[i] = sin(x[i]+1);
printf(" i %i %f %f \n",i,x[i],y[i]);
}

gr = new TGraph(n,x,y);
gr->GetHistogram()->SetXTitle("x axis");
gr->Fit("pol1");
gr->SetFillColor(19);
gr->SetLineColor(2);
gr->SetLineWidth(4);
gr->SetMarkerColor(4);
gr->SetMarkerStyle(4);

TPostScript mps("fff.ps");
mps.Range(8,8);
gr->Draw("AP");
c1->Draw();
mps.Close();

c1->Modified();
}