# Filling a 2D histogram

**URL:** <https://root-forum.cern.ch/t/filling-a-2d-histogram/33352>\
**Category:** Newbie\
**Created:** [March 28, 2019, 1:58pm UTC](https://root-forum.cern.ch/t/filling-a-2d-histogram/33352 "2019-03-28T13:58:48Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Aqsa\_Shaikh](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/a/50afbb/32.png) [@Aqsa\_Shaikh](https://root-forum.cern.ch/u/Aqsa_Shaikh)\
**Post date:** [March 28, 2019, 1:58pm UTC](https://root-forum.cern.ch/t/filling-a-2d-histogram/33352/1 "2019-03-28T13:58:48Z")

</div>

I am trying to draw a 2D histogram. so for beginning I am filling it with the following command

```auto
h->Fill(0,0,1);

```

but I am getting the error as

```auto
error: call to member function 'Fill' is ambiguous
      h->Fill(0,1,1);
      ~~~^~~~
/home/aqsa/Downloads/root_6.14/root-6.14.06_build/include/TH2.h:70:21: note: candidate function
   virtual Int_t Fill(Double_t x, Double_t y, Double_t w);
                    ^
/home/aqsa/Downloads/root_6.14/root-6.14.06_build/include/TH2.h:72:21: note: candidate function
   virtual Int_t Fill(const char *namex, Double_t y, Double_t w);

```

I read in the chapter 5 of histograms that one can fill it as h-\>(x,y,w) where w represents the weight. I am not able to understand why my code isn’t taking the fill command.

Later I am planning to fill it by using a text file which is like a 100\*100 matrix. I am assuming the matrix content will be my weight values and the number of rows and columns will be filled as x and y.

Please help I am attaching my macro

[histogram.c](https://root-forum.cern.ch/uploads/default/original/3X/a/a/aa6d14c37147b26e4271f4ce43da24d013c2eed0.c) (467 Bytes)  
.

ROOT: 6.14  
Platform: CentOS

---

<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:** [March 28, 2019, 2:03pm UTC](https://root-forum.cern.ch/t/filling-a-2d-histogram/33352/2 "2019-03-28T14:03:22Z")

</div>

```auto
h->Fill(0., 1., 1.);

```

---

<div class="post-metadata">

**Author:** ![couet](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/couet/32/12037_2.png) [@couet](https://root-forum.cern.ch/u/couet)\
**Post date:** [March 28, 2019, 2:13pm UTC](https://root-forum.cern.ch/t/filling-a-2d-histogram/33352/3 "2019-03-28T14:13:42Z")

</div>

[histogram.c](https://root-forum.cern.ch/uploads/default/original/3X/e/c/ec9dc0458d9e1c9da62f746f6820de9747a370ec.c) (455 Bytes)

 ![13](https://root-forum.cern.ch/uploads/default/original/3X/c/b/cbbc0291a3f327efa5252eadc67c04436716e433.jpeg)
