[ROOT] Length of axis divisions

From: Andreas Zoglauer (zog@ipp.mpg.de)
Date: Wed Mar 17 2004 - 17:09:13 MET


Hello,

This probably a really simple question, but I have not found anything 
helpful in the documentation...


I have a graph whose x-axis ranges from 0 to 360.
Thus a wanted to divide the x-axis in a way, that it shows the ticks 0, 
90, 180, 270 and 360.

How do I do this?
I tried it with SetNdivisions but this only gives me the ticks at 100, 
200 and 300..


Here is my example macro:

void Ticks()
{
   gROOT->Reset();
   TCanvas* c1 = new TCanvas("c1","Modulation");

   int NPoints = 360;
   TGraph* gr = new TGraph(NPoints);

   for (int i = 0; i < NPoints; ++i) {
     double x = i*360.0/NPoints;
     double y = 100 + 50*cos(2*x*TMath::Pi()/180);
     gr->SetPoint(i, x, y);
   }

   gr->Draw("AC");
   c1->Update();

   gr->GetHistogram()->SetXTitle("Azimuthal scatter angle");
   gr->GetHistogram()->SetYTitle("Counts");
   gr->GetHistogram()->SetAxisRange(0, 360, "X");
   gr->GetHistogram()->SetAxisRange(0, 200, "Y");
   gr->GetHistogram()->SetNdivisions(504, "X");
   c1->Modified();
}

Thanks,
Andreas



This archive was generated by hypermail 2b29 : Sun Jan 02 2005 - 05:50:06 MET