_ROOT Version: 6.14
_PYTHON Version : 3.6.7
_Platform: Debian 9
_Compiler: GCC 7.3.0
Hi, I frequently use the method below to reassign the axes of a square 2D histogram with physical units (in this case pixels are converted to mm)
def PixToMM(h1): sizeAxis = h1.GetXaxis().GetNbins() dimensions = ((sizeAxis-2)/43.5)*0.474*m h1.GetXaxis().SetLimits(0., dimensions) h1.GetYaxis().SetLimits(0., dimensions) h1.GetXaxis().SetTitle("mm") h1.GetYaxis().SetTitle("mm")
When I try a similar method for a TGraph object, it does not work as I wished it would. SetLimits() for the TGraph Object behaves like SetRangeUser() for a histogram.
Here, some pseudo code to illustrate what I mean :
bin_number = tgraph.GetXaxis().GetNbins() dimensions = ((bin_number-2)/43.5)*0.474*m tgraph.GetXaxis().SetLimits(0., dimensions) ---> This line behaves as SetRangeUser() normally does.
Do you have any suggestions how to convert the x-axis from pixels to mm if SetLimits does not work here?