Problems with a simple example

Pablo P Yepes (yepes@bonner-ibm2.rice.edu)
Thu, 9 Oct 1997 10:11:42 -0500


I want to plot the temperature of the Universe as a function of age. I =
took the graph.c macro from the tutorials area and modified. The result =
is this:

{
//
// To see the output of this macro, click begin_h
re</a>. end_html
//
gROOT->Reset();
c1 =3D new TCanvas("c1","Temperature of the Univers

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

Int_t n =3D 27;
Float_t x[n], y[n];
Float_t xx =3D 1.e-9 ;
Float_t yy ;
printf(" x =3D %f \n",xx);
for (Int_t i=3D0;i<n;i++) {
xx =3D xx * 10. ;
x[i] =3D xx ;
float xxx =3D log10(xx);
float yyy =3D exp(15 - (14./27.) * (xxx+9)) ;
y[i] =3D 15 - (14./27.) * (xxx+9) ;
printf(" i %i Time %6.2e Temp %6.2e \n",i, x[i],y[i]);
}
gr =3D new TGraph(n,x,y);
gr->SetFillColor(19);
gr->SetLineColor(2);
gr->SetLineWidth(4);
gr->Draw("ACP");

//Add axis titles.
//A graph is drawn using the services of the TH1F histogram class.
//The histogram is created by TGraph::Paint.
//TGraph::Paint is called by TCanvas::Update. This function is called =
by defau
t
//when typing <CR> at the keyboard. In a macro, one must force =
TCanvas::Update

c1->Update();
gr->GetHistogram()->SetXTitle("Log Time after the Big Bang =
(seconds)");
gr->GetHistogram()->SetYTitle("Log Temperature (Degrees Kelvin)");
}

I have two problems:

1) if I use the c1->Setlogy(). I get an error because some of the =
values are negative or zero. I don't see why because all the y values =
are >0.
2) if I don't use the Setlogy() option, the plot only cover the x range =
~10^16-10^18.

Thank you,
Pablo Yepes
Rice U