How to drawclone tf1 with axis title

Because my drawing function is very complex, so I want to put it in a function, but I can not drawclone the axis title. The following is the test code. Any idea to drawclone tf1 with axis title?


void draw(TCanvas&canvas)
TF1 f1{"",“sin(x)/x”,0,10};

int main()
TCanvas canvas;

Thanks to report. I see the issue you mention. I’ll check.

Try: void draw(TCanvas &canvas) { TF1 f1("", "sin(x)/x", 0, 10); TF1 *f = f1.DrawCopy(); // ... or ... ((TF1*)(f1.DrawClone())) f->GetXaxis()->SetTitle("hahaha"); f->GetXaxis()->CenterTitle(); canvas.Modified(); canvas.Update(); }

Yes, looking at the way it is done in the code, I think Pepe is right… Setting the title after DrawClone is the way to proceed.

Thank you, it works.

I am quite weird why the drawclone function of tf1 not copy the axis title. Because drawclone of tgraph will copy the axis title at the same time. Is it a bug?