Hi Olivier, Thank you very much for this little trick. It works perfectly. Ciao, Andreas Olivier Couet wrote: > Hi Andreas, > > Here is what you want: > > 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); > } > > TH1F *h1 = new TH1F("a","a",1000,0,360); > gr->SetHistogram(h1); > gr->Draw("AC"); > c1->Update(); > > gr->GetHistogram()->SetXTitle("Azimuthal scatter angle"); > gr->GetHistogram()->SetYTitle("Counts"); > gr->GetHistogram()->SetAxisRange(0, 200, "Y"); > gr->GetXaxis()->SetNdivisions(-504); > c1->Modified(); > } > > Explanation: TGraph creates internally an histogram to draw the graph. > That is the one you get when you do gr->GetHistogram(). That histogram has > by default 100 bins. In your case a 100 precision is not enough and you > see that "bin size effect". In this modified version of your macro I book > an histogram with 1000 bins and give it to the TGraph using > gr->SetHistogram. Having done that you do not need to set the X range of > the TGraph. > > Cheers, Olivier -- Andreas Zoglauer MPI fuer extraterrestrische Physik Phone: +49/89-30000-3848 Postfach 1312 Fax: +49/89-30000-3569 85741 Garching, Germany Email: zog@mpe.mpg.de
This archive was generated by hypermail 2b29 : Sun Jan 02 2005 - 05:50:06 MET