Re: Cannot force desired divisions using SetNdivisions

From: Eduard Avetisyan <Eduard.Avetisyan_at_desy.de>
Date: Sat, 10 Sep 2011 22:35:20 +0200

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 Sat Sep 10 2011 - 22:35:29 CEST

This archive was generated by hypermail 2.2.0 : Sun Sep 11 2011 - 17:50:01 CEST