Axis titles after DrawIntegral


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());

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. :
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!

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->GetYaxis()->SetTitle("#int_{0}^{2#pi} sin(X)");