Axis titles after DrawIntegral

Hello!

I have a problem with setting axis titles for function drawn by DrawIntegral method. Let’s look at test.C macro:

void test(){
TF1* fun = new TF1(“fun”,“sin(x)”, 0, TMath::TwoPi());
fun->GetXaxis()->SetTitle(“X”);
fun->GetYaxis()->SetTitle(“sin(X)”);
fun->DrawIntegral(“al”);
}

if you run this code, you will see that axis titles are not actually set.

At first glimpse I thought, that it may be due to fact, that DrawIntegral creates it’s own TGraph object, which is later drawn, and does not copy axes titles.
Another thing is that it may be caused by one of the draw options - “a”, which should (as far as I know) “suppress” drawing the axes. And there are two things. First - why axes are still drawn, even with the option “a” specified? Secondly - why if I specify only one option, i.e. :
fun->DrawIntegral(“l”);
axes are actually not drawn, plus the scale on both axes are not set properly.

Although there are few simple workarounds for this minor problem, I’d like to know if there is a “proper” way of setting axis titles after calling the TF1::DrawIntegral() method.

Thank you in advance!
Andrzej

Hi Andrzej,

the reason is that the object drawn is a TGraph representing the integral and not the function itself (as it’s reasonable since the integration procedure logically does not modify the integrand).
The solution is

void test(){
  auto fun = new TF1("fun","sin(x)", 0, TMath::TwoPi());
  auto g = (TGraph*) fun->DrawIntegral("al");
  g->GetXaxis()->SetTitle("X");
  g->GetYaxis()->SetTitle("#int_{0}^{2#pi} sin(X)");
}

Cheers,
Danilo