Programming Language: C++ (Cpp)

Class/Type: TH1D

Method/Function: SetMaximum

Examples at hotexamples.com: 30

TH1D is a class in the ROOT package library used for creating and manipulating 1-dimensional histograms. SetMaximum is a member function of TH1D class that sets the maximum value of the histogram bin contents. Here are some code examples using the SetMaximum function:

**Example 1:** Setting the maximum value of a histogram to a constant value

This example sets the maximum value of all bins in the histogram to 10.

**Example 2:** Setting the maximum value of a histogram based on the maximum bin content

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

This example sets the maximum value of all bins in the histogram 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.

Frequently Used Methods

Frequently Used Methods

Frequently Used Methods

Frequently Used Methods