Error in <THistPainter::PaintInit>: log scale requested with a negative argument (-0.141557)

Dear experts

I want to calculate the time cost for two different algorithms for convolution, then I draw them on a TMultiGraph which contains 2 TGraph inside. I confirmed every point is positive x and y, but I got the error when I try to TCanvas::SetLogx() and TCanvas::SetLogy(), why?

I attach my working example here:
checkTimeCostFFT.cxx (4.7 KB)
graph.root (6.9 KB)

And the output of values says they are all positive:

0th loop finished with inputLength = 1
    normal convolution time cost: 2.625e-06
    FFT    convolution time cost: 0.391761
1th loop finished with inputLength = 4
    normal convolution time cost: 9.417e-06
    FFT    convolution time cost: 0.662822
2th loop finished with inputLength = 16
    normal convolution time cost: 6.8792e-05
    FFT    convolution time cost: 1.12083
3th loop finished with inputLength = 64
    normal convolution time cost: 0.000505083
    FFT    convolution time cost: 1.80859
4th loop finished with inputLength = 256
    normal convolution time cost: 0.00397829
    FFT    convolution time cost: 2.83119

ROOT version: 6.32.08

I’ll check

I am missing the file graph.root.

Oh, sorry for that, now I uploaded the graph.root

And I confirmed that this error is from SetLogy(), not SetLogx()

The painting method of TMultigraph keeps a margin of 0.0001 of the y range to avoid the graphs’ points overlap the Y axis. In your case this value is too big and the minimum of the axis becomes negative. You can bypass this problem with some code like:

    TMultiGraph* g_time = new TMultiGraph();
    g_time->Add(g_normal);
    g_time->Add(g_FFT);
    
    g_time->GetXaxis()->SetTitle("Input vector length");
    g_time->GetYaxis()->SetTitle("Time cost [s]");
    printf("g_time minimum = %g\n",g_time->GetHistogram()->GetMinimum()); // shows the axis minimum is < 0
    g_time->SetMinimum(0.000001); // define a positive minimum
    c->SetLogx();
    c->SetLogy();

    g_time->Draw("AP")

Thank you, this fixed the problem, but I found if I change the loop to 10 then only the last 4 points are shown, can you please have a look?
checkTimeCostFFT.cxx (5.0 KB)