RE: Cannot force desired divisions using SetNdivisions

From: Paul Miyagawa <Paul.Miyagawa_at_cern.ch>
Date: Mon, 12 Sep 2011 10:16:50 +0000


Hi Olivier,

Thanks for your reply. What exactly do you mean by a real log Axis? Do you mean saving a histogram as Energy rather than log Energy, then setting the canvas to log scale? That wouldn't do what I need because that would give me even bins in Energy, when I need even bins in log Energy. The only other option I could try is to calculate and set the bin limits manually.

Paul



From: Olivier Couet
Sent: 12 September 2011 10:46
To: Paul Miyagawa
Cc: Eduard Avetisyan; roottalk_at_root.cern.ch Subject: Re: [ROOT] Cannot force desired divisions using SetNdivisions

Hi,

You are using alphanumeric labels. SetNdivisions does not act on them. There are examples showing how to use alphameric labels in $ROOTSYS/tutorials/hist Have you tried to use real log Axis ? I suppose you did and you do not like the result.

Olivier

On Sep 11, 2011, at 2:55 PM, Paul Miyagawa wrote:

Hi Eduard,

Thanks for your suggestion. I had tried it before (and again just now), but it still plots incorrectly.

Cheers,
Paul

-----Original Message-----
From: Eduard Avetisyan [mailto:Eduard.Avetisyan_at_desy.de] Sent: 10 September 2011 21:35
To: Paul Miyagawa
Cc: roottalk_at_root.cern.ch<mailto:roottalk_at_root.cern.ch> Subject: Re: [ROOT] Cannot force desired divisions using SetNdivisions

Hi Paul,

Try to plug it like in the modified example:

On Sat, 10 Sep 2011, Paul Miyagawa wrote:

Hello,

I am trying to draw a histogram with the x-axis as log Energy ranging from 1e-15 MeV to 1e6 MeV (i.e., -15 to +6). I would like to have primary tick marks every 3 decades and secondary tick marks every decade. If I have calculated properly, I should SetNdivisions(307). However, no matter what I try I cannot force this; Root plots as if SetNdivisions(210). The following macro is a distillation of what I do:

{
 TH1F *mhereg = new TH1F( "loge", "log Energy [MeV]", 210, -15, 6 );  mhereg->SetNdivisions( -307 );
 TAxis *xhereg = mhereg->GetXaxis();
 for (int i=-15; i<6; i+=3) {
   char blabel[100];
   sprintf( blabel, "10^{%d}", i );
   xhereg->SetBinLabel( 1+10*(i+15), blabel );    mhereg->Fill(i);
 }
 mhereg->Draw();
   xhereg = mhereg->GetXaxis();
   xhereg->SetNdivisions( -307 );
   mhereg->Draw();
}

The idea is to make the Ndivisions call AFTER having the histogram drawn. Just an idea...

Cheers
Eduard

I have tried many variations of SetNdivisions, including:

xhereg->SetNdivisions( -307 );
xhereg->SetNdivisions( 307, kFALSE );
xhereg->SetNdivisions( 7, 3, 0, kFALSE );

How can I force Root to give what I want? Thanks for any help.

Cheers,
Paul Received on Mon Sep 12 2011 - 12:16:58 CEST

This archive was generated by hypermail 2.2.0 : Mon Sep 12 2011 - 17:50:01 CEST