[ROOT] Problems with SetNdivisions

From: Steffen Grohmann (Steffen.Grohmann@cern.ch)
Date: Tue Jul 09 2002 - 16:30:07 MEST


Hello,

I have problems to format axes using SetNdivisions. In the example below the
intension is to create a y-axis with 4 primary and 4 secondary divisions. If
I use SetNdivisions(404), the program doesn't follow the request but I can
at least force it with (-404). This, however, does not work on an axis drawn
with TGaxis, e.g. to draw another y-axis on the right of the graph. There I
cannot use the minus.

Scaling the right axis from 0 to 800, ndiv=404 leads to 1 first and 1
secondary division. By trial and error I fond that ndiv=505 works. However,
scaling the same axis from 0 to 1600, neither ndiv 404 nor 505 nor anything
else seems to help.

Is there some way to generally switch off the optim function for dividing
axis? I have the impression that the operation of the command is somehow
contradicting to what is written in the manual.

Best regards,
Steffen
{
#include <time.h>
gROOT->Reset();
gStyle->SetOptTitle(kFALSE);
TFile *f = new TFile("time.root","RECREATE");
TCanvas *ct = new TCanvas("ct","example",100,100,500,500);
ct->Range(0,0,1,1);
Int_t n=2;
Float_t x[n] = {600, 3600};
Float_t y[n] = {1000, 6000};
TGraph *gr1 = new TGraph(n,x,y);
ct->DrawFrame(0,0,3600,8000);
gr1->Draw("L");
gr1->GetXaxis()->SetTimeDisplay(1);
gr1->GetXaxis()->SetTimeFormat("%H:%M");
gr1->GetYaxis()->SetNdivisions(-506);
gr1->GetYaxis()->SetNdivisions(-404);
TGaxis *axisT = new TGaxis(0,8000,3600,8000,0,30,506,"-U");
axisT->Draw();
TGaxis *axisR = new TGaxis(3600,0,3600,8000,0,1600,505,"+");
axisR->Draw();
ct->Modified();
ct->Update();
f->Write();
}



This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:50:59 MET