Non responsive SetNdivisions

I am trying to set the number of divisions for a TProfile plot. A quick example to replicate what I see is this:

c = TCanvas('c1','',700,500)
c.SetLogy()
p = TProfile('profile','',10,0,10)
p.Fill(5.,0.1)
p.Draw()

Originally I tried setting the number of divisions using:

p.GetYaxis().SetNdivisions(...)

When this didn’t work I tried changing the number of divisions using the canvas editor. This too failed. It seems to behave properly with linear scales but not log with a log scale.

The fundamental problem I am having is that when plotting in log scale over a small range the number of divisions is far too small, but SetMoreLogLabels creates too many labels.

Thanks for your help,

Peter

In log scale the number of division is always automatic.

Thank you for your response. Could you recommend a way to gain more control for log axis? Preferably the easiest next to leaving it automatic.

Thanks,

Peter

There are only 2 ways:

  • You can change the number of primary division. But it is always optimized and the number you give is always a maximum of decades (try interactively).

  • SetMoreLogLabels

I have tried SetMoreLogLabels however this does not optimize very well in my plots all the time. What I mean by “all the time” is that I am trying to automatically generate a large number plots without any interactive tweaking.

Most of the plots come out looking great without any need to play with SetNdivisions or SetMoreLogLabels, but in cases when the y-axis range is small it can happen that there are two few labels. In a subset of these cases SetMoreLogLabels sets too many labels!

I haven’t been able to find clear information of exactly how SetMoreLogLabels is supposed to act.

Thanks for your help,

Peter

Yes. “more log label”, is alos kind of automatic …
I am afraid I have no more hints to give you.
Can you produce a smal macro showing what you do not like ? (preferably not in Python)

I’ve attached a macro which shows the problem I have. This may actually deserve a separate thread, because this is some very weird behavior and doesn’t really have to do with SetNdivisions anymore.

In the macro I am changing the style so the bottom margin is slightly bigger. When this is included all of the secondary divisions include a label when I use SetMoreLogLabels. When I comment out this style change or set the bottom margin to something smaller than .145, the number of secondary divisions that include a label is smaller. Is this behavior understood? If it is could it please be explained because I would like not all of the secondary divisions to include a label when SetMoreLogLabels is used.

Sorry, I didn’t include the macro:

{
gStyle->SetPadBottomMargin(0.16);

TProfile* p = new TProfile(“test”,"",10,0,10);

p->Fill(1,70);
p->Fill(2,100);
p->Fill(3,150);
p->Fill(4,170);
p->Fill(5,200);
p->Fill(6,220);
p->Fill(7,240);

p->Fill(8,280);
p->Fill(9,300);

p->GetYaxis()->SetRangeUser(50,400);
p->GetYaxis()->SetMoreLogLabels();
p->GetYaxis()->SetLabelSize(0.05);
p->GetXaxis()->SetLabelSize(0.05);

TCanvas* c = new TCanvas(“c”,"",700,500);
c->SetLogy();

p->Draw(“H”);
}

The More Log label option is entirely automatic and takes the axis size and label size into account to decide which labels should be drawn. You have no control about it. Mays be you can decrease the label size a bit in that particular case.

This seems like bad behavior, if the axis size is getting smaller (when the bottom margin gets larger) More log labels decides to include more labels?

I agree it does not look logical. I will make a bug report.

I submitted a report:
savannah.cern.ch/bugs/index.php?89786

I may have misunderstood the bug report, but to me it looks like you say that decreasing the canvas margin makes more log labels, when it is actually the other way around. I apologize if this my misunderstanding.

yes … sorry … I changed the bug report

it is more complex… it depends alos on the window size … :frowning:

I guess that makes sense. Is there a way for a user to see exactly how this is configured?

no … unless you look at the code… it was supposed to be automatic and therefore there no real documentation on that.