TH1D histogram("histogram","Title;X Axis;Y Axis", 100, 0, 100); // Create histogram with 100 bins and range from 0 to 100 histogram.SetMaximum(10); // Set the maximum value of all bins to 10
TH1D histogram("histogram","Title;X Axis;Y Axis", 100, 0, 100); // Create histogram with 100 bins and range from 0 to 100 // Fill histogram with some data for(int i=0; i<1000; i++) { histogram.Fill(rand()%100 + 1); // Fill histogram with random values between 1 and 100 } histogram.SetMaximum(histogram.GetMaximum()*1.2); // Set the maximum value of all bins to 120% of the maximum bin contentThis example fills the histogram with some random data and then sets the maximum value of all bins to 120% of the maximum bin content. Overall, the SetMaximum function is useful for controlling the y-axis scale of a histogram. The package library for TH1D is ROOT.