Changing the y axis range in a TH1F in root

In summary, the conversation discusses how to change the y-axis of a 1D graph in root from showing the number of entries in each bin to showing the number of entries divided by the total number of entries. The solution suggested is to look for a suitable member in the online description of classes or to use the methods involving "normalize".
  • #1
lavster
217
0
hi, I am plotting a 1D graph in root (TH1F pointer). currently the y-axis gives the number of entries in each bin along my x-axis. how do i change it so that it is actually the number of entries in each bin divided by the total number of entries.

thanks
 
Technology news on Phys.org
  • #2
I cannot answer your question but from my experience with root: Get to the online description of the classes and look for a suitable member. The description would be here http://root.cern.ch/root/html/TH1.html but I usually just google for "root cern <classname>". In your particular example, I'd try the methods involving something like "normalize", e.g. "DrawNormalized".
 

1. How do I change the y axis range in a TH1F in root?

To change the y axis range in a TH1F in root, you can use the SetMinimum() and SetMaximum() functions. These functions allow you to specify the minimum and maximum values for the y axis range.

2. Can I specify a logarithmic scale for the y axis in a TH1F?

Yes, you can use the SetLogy() function to specify a logarithmic scale for the y axis in a TH1F. This will change the scale to a logarithmic one and also adjust the y axis range accordingly.

3. How can I set a custom y axis range in a TH1F?

To set a custom y axis range in a TH1F, you can use the SetRangeUser() function. This allows you to specify a minimum and maximum value for the y axis range, regardless of the data in the histogram.

4. Can I change the y axis range based on the maximum value in my data?

Yes, you can use the GetMaximum() function to retrieve the maximum value in your data, and then use this value to set the maximum for the y axis range using the SetMaximum() function. This will ensure that the entire data is visible on the histogram.

5. How can I reset the y axis range to the default in a TH1F?

To reset the y axis range to the default in a TH1F, you can use the Reset() function. This will reset all histogram settings, including the y axis range, to the default values.

Similar threads

  • Programming and Computer Science
Replies
17
Views
1K
  • High Energy, Nuclear, Particle Physics
Replies
9
Views
2K
  • Programming and Computer Science
Replies
6
Views
1K
  • Programming and Computer Science
Replies
30
Views
4K
  • Set Theory, Logic, Probability, Statistics
2
Replies
37
Views
4K
  • Programming and Computer Science
Replies
12
Views
1K
Replies
3
Views
4K
Replies
1
Views
1K
  • Calculus and Beyond Homework Help
Replies
3
Views
120
Replies
13
Views
1K
Back
Top