Hello,
The way to do it would be:
gr->GetHistogram()->SetAxisRange(0, 360, "X");
gr->GetHistogram()->SetAxisRange(0, 200, "Y");
gr->GetXaxis()->SetNdivisions(-504);
a negative number of divisions meaning that the divisions should not be
optimize. But doing that I do not get exactly 360 as upper limit...
That's weird ... I'll investigate.
Olivier
On Wed, 17 Mar 2004, Andreas Zoglauer wrote:
>
> 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
>
>
>
>
--
Org: CERN - European Laboratory for Particle Physics.
Mail: 1211 Geneve 23 - Switzerland Mailbox: J25910
E-Mail: Olivier.Couet@cern.ch Phone: +41 22 7676522
WWW: http://cern.ch/Olivier.Couet/ Fax: +41 22 7677155
This archive was generated by hypermail 2b29 : Sun Jan 02 2005 - 05:50:06 MET