TH1D* hist = new TH1D("myhist", "My Histogram", 100, 0, 10); TAxis* xAxis = hist->GetXaxis();
TH1D* hist = (TH1D*) rootFile->Get("myhist"); if(hist){ TAxis* xAxis = hist->GetXaxis(); int numBins = xAxis->GetNbins(); double binWidth = xAxis->GetBinWidth(1); double binLowerEdge = xAxis->GetBinLowEdge(1); double binUpperEdge = xAxis->GetBinUpEdge(numBins); }In this example, an existing histogram object is retrieved from a ROOT file, then the X axis is obtained using GetXaxis. The number of bins, bin width, and lower/upper edges of the first and last bins are then accessed using TAxis methods. If the histogram object could not be retrieved from the file, hist will be a nullptr. Package/Library: ROOT (CERN)