Log plot showing error

ROOT Version: 6.24/06
Platform: Ubuntu 20.04.3
Compiler: g++(9.3.0)

In this new version I was trying to plot a graph with a Y-axis in log-scale. But that is returning error messages with blank canvas. But this is working fine with older versions like v6.20. The message I’m getting is

Processing Test.C...
Error in <THistPainter::PaintInit>: log scale requested with a negative argument (-0.050000)
Error in <THistPainter::PaintInit>: log scale requested with a negative argument (-0.050000)
Info in <TCanvas::Print>: pdf file Test.pdf has been created

Any idea how to resolve this issue will be appreciated. I have attached herewith a sample macro and sample data file.
Test.C (889 Bytes)
Test.txt (591 Bytes)

Thanks and regards,

Root draws multigraphs (and graphs) in a histogram, with automatic binning. If you do

cout << multigraph->GetHistogram()->GetMinimum() << endl;

after drawing, you will see that the minimum (y value) in your case is -0.05, even though you don’t have negatives in your data.
You can set a minimum greater than zero by hand, after drawing but before setting the log scale. Just make sure it’s smaller than your lowest data point; for your case, e.g.


since your lowest is 1.11e-2

Thanks a lot @dastudillo, that solves the issue.
But that made me wonder what if I have indeed negative values of the variable on the Y-axis. Wouldn’t it be possible to plot in log-scale? I suppose this is happening because a bin-content cannot be negative, right?

Thanks again,

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.