#include "TH1F.h" // Initializing a histogram with 100 bins between 0 and 100 TH1F* hist = new TH1F("myhist", "My Histogram", 100, 0, 100); // Setting the minimum value of the Y-axis to 0 hist->SetMinimum(0); // Fill the histogram with some data hist->Fill(20); hist->Fill(30); hist->Fill(40);
#include "TH1F.h" // Initializing a histogram with 100 bins between 0 and 100 TH1F* hist = new TH1F("myhist", "My Histogram", 100, 0, 100); // Fill the histogram with some data hist->Fill(20); hist->Fill(30); hist->Fill(40); // Determine the minimum and maximum values of the Y-axis float ymin = hist->GetMinimum(); float ymax = hist->GetMaximum(); // Expand the Y-axis range by 10% float ydiff = ymax - ymin; hist->SetMinimum(ymin - ydiff*0.1); hist->SetMaximum(ymax + ydiff*0.1);This example initializes a histogram with 100 bins between 0 and 100 and fills it with some data. It then determines the minimum and maximum values of the Y-axis and expands the Y-axis range by 10%. Package library: ROOT.