TH1F *hist = new TH1F("hist", "My histogram", 100, 0, 10); // Fill the histogram with data... hist->Draw(); // Before scaling hist->GetYaxis()->SetRangeUser(0, 50); // Scale the Y-axis to show values up to 50 hist->Draw(); // After scaling
TH1F *hist = new TH1F("hist", "My histogram", 3, 0, 3); hist->SetBinContent(1, 10); hist->SetBinContent(2, 5); hist->SetBinContent(3, 15); hist->Draw(); // Before changing labels hist->GetYaxis()->SetBinLabel(1, "Low"); hist->GetYaxis()->SetBinLabel(2, "Medium"); hist->GetYaxis()->SetBinLabel(3, "High"); hist->Draw(); // After changing labelsIn this example, we create a small histogram with 3 bins and fill it with some data. We then draw the histogram before changing the labels of its Y-axis, and after setting custom labels for each bin. The package library for this code is ROOT.