Problems with a simple example

From: Pablo P Yepes (yepes@bonner-ibm2.rice.edu)
Date: Thu Oct 09 1997 - 17:11:42 MEST


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 = 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 = 27;
   Float_t x[n], y[n];
   Float_t xx = 1.e-9 ;
   Float_t yy ;
   printf(" x = %f  \n",xx);
   for (Int_t i=0;i<n;i++) {
     xx   = xx * 10. ;
     x[i] = xx ;
     float xxx = log10(xx);
     float yyy = exp(15 - (14./27.) * (xxx+9)) ;
     y[i] = 15 - (14./27.) * (xxx+9) ;
     printf(" i %i Time %6.2e Temp %6.2e \n",i, x[i],y[i]);
   }
   gr = 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



This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:26:21 MET