# How to set a cumulative histogram's y-axis to a percentage scale instead of the number of bins

**URL:** <https://root-forum.cern.ch/t/how-to-set-a-cumulative-histograms-y-axis-to-a-percentage-scale-instead-of-the-number-of-bins/52697>\
**Category:** Newbie\
**Tags:** hist, root\
**Created:** [December 8, 2022, 1:37pm UTC](https://root-forum.cern.ch/t/how-to-set-a-cumulative-histograms-y-axis-to-a-percentage-scale-instead-of-the-number-of-bins/52697 "2022-12-08T13:37:05Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![edus1898](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/edus1898/32/31779_2.png) [@edus1898](https://root-forum.cern.ch/u/edus1898)\
**Post date:** [December 8, 2022, 1:37pm UTC](https://root-forum.cern.ch/t/how-to-set-a-cumulative-histograms-y-axis-to-a-percentage-scale-instead-of-the-number-of-bins/52697/1 "2022-12-08T13:37:06Z")

</div>

My code is the following:

```auto
{
TCanvas *c1 = new TCanvas();
h = new TH1D ("h", "Distanza Angolare; Distanza Angolare (deg); Conteggi; ", 100, 0, 5); 
 
fstream file;
file.open("Dist_Ang.txt", ios::in);

double value;

while(1)
{
    file >> value;
    h->Fill(value); 
    if(file.eof()) break;
}

file.close();

TH1* hc = h->GetCumulative();
h->SetFillColor(kBlue);
hc->Draw();
       
}

```

How do I make it so that the y axis gives me the percentage of points instead of the number of points?

---

<div class="post-metadata">

**Author:** ![Wile\_E\_Coyote](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/wile_e_coyote/32/12417_2.png) [@Wile\_E\_Coyote](https://root-forum.cern.ch/u/Wile_E_Coyote)\
**Post date:** [December 8, 2022, 2:22pm UTC](https://root-forum.cern.ch/t/how-to-set-a-cumulative-histograms-y-axis-to-a-percentage-scale-instead-of-the-number-of-bins/52697/2 "2022-12-08T14:22:09Z")

</div>

Try: `hc->Scale(100. / h->Integral());`
